aboutsummaryrefslogtreecommitdiff
path: root/src/components/video.py
diff options
context:
space:
mode:
authortassaron2017-07-15 13:13:53 -0400
committertassaron2017-07-15 13:13:53 -0400
commitbcb8f27c2e4434d2296dcd66bf279b76ee0d0a4f (patch)
tree2a7f9df3eebbae8da4317516f84dfe7490b5d36a /src/components/video.py
parent62ab09e3f36dcaf6c1a4680dc6c4d048fb2e165c (diff)
use -t on inputs so ffmpeg knows when to stop filters
+ better feedback in cmd mode
Diffstat (limited to 'src/components/video.py')
-rw-r--r--src/components/video.py38
1 files changed, 26 insertions, 12 deletions
diff --git a/src/components/video.py b/src/components/video.py
index b3b6a59..0b93293 100644
--- a/src/components/video.py
+++ b/src/components/video.py
@@ -116,6 +116,7 @@ class Component(Component):
page = self.loadUi('video.ui')
self.videoPath = ''
self.badVideo = False
+ self.badAudio = False
self.x = 0
self.y = 0
self.loopVideo = False
@@ -161,22 +162,14 @@ class Component(Component):
if self.useAudio:
props.append('audio')
- # test if an audio stream really exists
- audioTestCommand = [
- self.core.FFMPEG_BIN,
- '-i', self.videoPath,
- '-vn', '-f', 'null', '-'
- ]
- try:
- checkOutput(audioTestCommand, stderr=subprocess.DEVNULL)
- except subprocess.CalledProcessError:
- self.badAudio = True
+ self.testAudioStream()
+ if self.badAudio:
return ['error']
return props
def error(self):
- if hasattr(self, 'badAudio'):
+ if self.badAudio:
return "Could not identify an audio stream in this video."
if not self.videoPath:
return "There is no video selected."
@@ -185,6 +178,20 @@ class Component(Component):
if self.badVideo:
return "The video selected is corrupt!"
+ def testAudioStream(self):
+ # test if an audio stream really exists
+ audioTestCommand = [
+ self.core.FFMPEG_BIN,
+ '-i', self.videoPath,
+ '-vn', '-f', 'null', '-'
+ ]
+ try:
+ checkOutput(audioTestCommand, stderr=subprocess.DEVNULL)
+ except subprocess.CalledProcessError:
+ self.badAudio = True
+ else:
+ self.badAudio = False
+
def audio(self):
return (self.videoPath, {'map': '-v'})
@@ -277,7 +284,7 @@ class Component(Component):
if not arg.startswith('preset=') and '=' in arg:
key, arg = arg.split('=', 1)
if key == 'path' and os.path.exists(arg):
- if os.path.splitext(arg)[1] in self.core.videoFormats:
+ if '*%s' % os.path.splitext(arg)[1] in self.core.videoFormats:
self.page.lineEdit_video.setText(arg)
self.page.spinBox_scale.setValue(100)
self.page.checkBox_loop.setChecked(True)
@@ -285,10 +292,17 @@ class Component(Component):
else:
print("Not a supported video format")
quit(1)
+ elif arg == 'audio':
+ if not self.page.lineEdit_video.text():
+ print("'audio' option must follow a video selection")
+ quit(1)
+ self.page.checkBox_useAudio.setChecked(True)
+ return
super().command(arg)
def commandHelp(self):
print('Load a video:\n path=/filepath/to/video.mp4')
+ print('Using audio:\n path=/filepath/to/video.mp4 audio')
def scale(scale, width, height, returntype=None):