Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-blocking PyAudio implementation + project refactor #2

Merged
merged 59 commits into from Dec 10, 2019
Merged
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
798aa15
Add a basic PyAudio example script using the callback API
romanroibu Nov 22, 2019
ffe5487
Merge branch 'master' into nonblocking-callback-api
romanroibu Nov 25, 2019
24390a9
Add frame_rate property to PyAudioCodec
romanroibu Nov 27, 2019
1d65e5a
Add WIP implementation for threaded audio PyAudio source and PyAV fil…
romanroibu Nov 27, 2019
4611904
Move current API into blocking submodule
romanroibu Nov 27, 2019
028cd72
Update examples/_pupil_audio.py to re-export from blocking submodule
romanroibu Nov 27, 2019
b85bb64
Create pupil_audio.utils package
romanroibu Nov 27, 2019
8483263
Move PyAudio helpers into pupil_audio.utils.pyaudio module
romanroibu Nov 27, 2019
2065e41
Create pupil_audio package
romanroibu Nov 27, 2019
0abf330
Add pipeline using nonblocking PyAudio API and PyAV
romanroibu Nov 27, 2019
260724b
Add project configurations to make it installable using pip
romanroibu Nov 27, 2019
a84e4d5
Add example.utils module with helpers to run the example scripts
romanroibu Nov 27, 2019
b062664
Ignore outputs/ inside examples/
romanroibu Nov 27, 2019
a0b3f40
Simplify examples/pyaudio_in_pyav_out_api.py into examples/capture_no…
romanroibu Nov 27, 2019
6c4333a
Pass frame_rate to the WaveCodec
romanroibu Nov 27, 2019
515b97a
Simplify PyAudio input WAVE file output example script
romanroibu Nov 27, 2019
7eb30e2
Simplify example script with PyAudio input and PyAV output
romanroibu Nov 27, 2019
8d12e78
Remove unused raw PyAudio callback API example script
romanroibu Nov 27, 2019
8f34edb
Simplify example script for enumerating input/output devices
romanroibu Nov 27, 2019
e927170
Refactor example script that uses raw PyAudio library to enumerate al…
romanroibu Nov 27, 2019
4b69035
Update README.md
romanroibu Nov 27, 2019
790c8ec
Add frame_rate argument to nonblocking pyaudio2pyav example
romanroibu Nov 28, 2019
bfc02ea
Update get_output_file_path to filter out empty filename parts
romanroibu Nov 28, 2019
16c5c22
Update nonblocking pyaudio2pyav example to use click for cli
romanroibu Nov 28, 2019
aebcbb3
Update nonblocking pyaudio2pyav to use an optional fixed recording le…
romanroibu Nov 28, 2019
6f26b04
Add start and stop methods for transcoder instance
romanroibu Nov 28, 2019
2c81900
Update pyaudio2pyav pipeline to pass time_info instead of timestamp
romanroibu Nov 28, 2019
5adafaf
Update PyAudio2PyAVCapture to optionally accept a transcoder class fo…
romanroibu Nov 28, 2019
1ae07d1
Implement a custom transcoder for pyaudio2pyav example
romanroibu Nov 28, 2019
ff1fcbe
Use the custom transcoder in pyaudio2pyav example if the debug flag i…
romanroibu Nov 28, 2019
e2d05ef
Set pts explicitly
papr Nov 28, 2019
aad79e6
Calculate realtime PTS
papr Nov 28, 2019
9f0ad05
Handle case where no mic is connected
papr Nov 28, 2019
8f26e52
Revert "Calculate realtime PTS"
papr Nov 28, 2019
87dbf31
Merge remote-tracking branch 'rom/gitignore_changes' into nonblocking…
papr Nov 28, 2019
337e293
Ignore audio binaries
papr Nov 28, 2019
7bf20d9
Do not overwrite frame pts with None
papr Nov 28, 2019
8077d25
Verify configuration on runtime
papr Nov 28, 2019
1ed42cd
Allow PyAudio2PyAVCapture to take optional dtype argument
romanroibu Dec 2, 2019
7d767cb
Fix typo in pyav_format property
romanroibu Dec 2, 2019
1530be4
Add comment in PyAudio2PyAVTranscoder
romanroibu Dec 2, 2019
dad48ba
Update PyAudio helpers for getting devices to accept an optional unow…
romanroibu Dec 2, 2019
75d4712
Update PyAVFileSink to write timestamps to "*_timestamps.npy"
romanroibu Dec 2, 2019
b38f21e
Make _DebugDataStore.is_opened a property
romanroibu Dec 3, 2019
624ded3
Use Queue.get with timeout instead of Queue.get_nowait with explicit …
romanroibu Dec 3, 2019
e3097cb
Fix error where the PyAV stream was flushed even if no data was writen
romanroibu Dec 4, 2019
3a8f7f8
Add lock around _get_devices_infos_by_api function
romanroibu Dec 4, 2019
b109821
Refactor utils.pyaudio API to make the module cleaner and safer to use
romanroibu Dec 4, 2019
c6daad3
Add API enumeration to enumerate_devices_raw_pyaudio example
romanroibu Dec 4, 2019
a918111
Improve default HostApiInfo resolution with fallback to any supported…
romanroibu Dec 4, 2019
05d7bc9
Remove deprecated utils.pyaudio functions and replace calls with new API
romanroibu Dec 4, 2019
ef9ff87
Add comment and improve formatting in utils.pyaudio
romanroibu Dec 4, 2019
97a2465
Add implementation of PyAudioDeviceMonitor and PyAudioBackgroundDevic…
romanroibu Dec 4, 2019
e37fca3
Add example script to showcase how to use PyAudioDeviceMonitor and Py…
romanroibu Dec 4, 2019
72bcd64
Remove code used for debugging timestamps file names
romanroibu Dec 4, 2019
b7bb632
Fix TimeInfo import issue in nonblocking/pyaudio2pyav.py
romanroibu Dec 4, 2019
f68240a
Export nonblocking API and utils.pyaudio from top-level module
romanroibu Dec 4, 2019
bbf841e
Ignore "default" special device on Linux
romanroibu Dec 4, 2019
14dff50
setup.py: Install all sub packages
papr Dec 9, 2019
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Set pts explicitly

  • Loading branch information
papr committed Nov 28, 2019
commit e2d05efc7356bc5c91fd11875252b59bf598d068
@@ -1,6 +1,7 @@
import queue
import threading
import typing as T
from fractions import Fraction

import numpy as np
import pyaudio
@@ -68,6 +69,7 @@ def __init__(self, frame_rate, channels, dtype=np.dtype("int16")):
self.frame_rate = frame_rate
self.channels = channels
self.dtype = dtype
self.num_encoded_frames = 0

def start(self):
pass
@@ -168,5 +170,8 @@ def transcode(self, in_frame: np.ndarray, time_info: pyaudio_utils.TimeInfo) ->
plane.update(tmp_frame[i, :])

out_frame.rate = self.frame_rate
out_frame.time_base = Fraction(1, self.frame_rate)
out_frame.pts = out_frame.samples * self.num_encoded_frames
self.num_encoded_frames += 1

return out_frame, time_info.input_buffer_adc_time
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.