Skip to content
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

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