Skip to content

Allows for No Audio to be selected in the audio devices. #3

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ def __init__(self):

device = Device()

nullDevice = Device()
nullDevice.name = "No Audio"
self._devices.append(nullDevice)

# =========================================================================
def deviceSet(self, index):

Expand Down
33 changes: 24 additions & 9 deletions recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ def videoArgs(self):
@property
def audioArgs(self):

# Return no arguments for audio if we are using no audio device.
if not self._audioDevice.api or not self._audioDevice.source:
return ""

return '-f {f} '.format(f=self._audioDevice.api) + \
'-ac 1 ' + \
'-ar 48000 ' + \
Expand All @@ -80,15 +84,26 @@ def audioArgs(self):
@property
def outputArgs(self):

return '-map 0:0 ' + \
'-map 1:0 ' + \
'-vcodec mpeg4 ' + \
'-qscale:v 1 ' + \
'-acodec pcm_s16be ' + \
'-qscale:a 1 ' + \
'-f segment ' + \
'-segment_time 300 ' + \
'{d}recording.%04d.mov '.format(d=self._workDir)
# Mapping and output codecs need to be omitted with no audio.
hasAudio = self._audioDevice.api and self._audioDevice.source

output = '-map 0:0 '

if hasAudio:
output += '-map 1:0 '

output += '-vcodec mpeg4 ' + \
'-qscale:v 1 '

if hasAudio:
output += '-acodec pcm_s16be '

output += '-qscale:a 1 ' + \
'-f segment ' + \
'-segment_time 300 ' + \
'{d}recording.%04d.mov '.format(d=self._workDir)

return output

# =============================================================================