diff --git a/audio.py b/audio.py index aaf8525..b652a3c 100644 --- a/audio.py +++ b/audio.py @@ -54,6 +54,10 @@ def __init__(self): device = Device() + nullDevice = Device() + nullDevice.name = "No Audio" + self._devices.append(nullDevice) + # ========================================================================= def deviceSet(self, index): diff --git a/recorder.py b/recorder.py index 1b886b7..1eb862d 100644 --- a/recorder.py +++ b/recorder.py @@ -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 ' + \ @@ -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 # =============================================================================