From 3d3134f39932da90e18e4f0651162952811a1651 Mon Sep 17 00:00:00 2001 From: Michael Kessler Date: Wed, 21 Jan 2015 16:55:16 -0800 Subject: [PATCH 1/2] Allows for the option of recording no audio. --- audio.py | 4 ++++ recorder.py | 4 ++++ 2 files changed, 8 insertions(+) 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..8c61434 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 ' + \ From f34f9cf93dbea869585a6eb23bc5a8fa61ba3171 Mon Sep 17 00:00:00 2001 From: Michael Kessler Date: Wed, 21 Jan 2015 17:54:02 -0800 Subject: [PATCH 2/2] Ignores audio channel for output arguments when using "No Audio" --- recorder.py | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/recorder.py b/recorder.py index 8c61434..1eb862d 100644 --- a/recorder.py +++ b/recorder.py @@ -84,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 # =============================================================================