From aa464632c64725201dc7584ebf6bf2c3d06b47b6 Mon Sep 17 00:00:00 2001 From: tassaron Date: Sun, 16 Jul 2017 23:13:00 -0400 Subject: new hotkey to preview the ffmpeg command --- setup.py | 2 +- src/components/video.py | 4 ++-- src/core.py | 6 +++++- src/mainwindow.py | 19 ++++++++++++++++++- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 71dc51f..6ef688a 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ setup( 'Topic :: Multimedia :: Video :: Non-Linear Editor', ], keywords=['visualizer', 'visualization', 'commandline video', - 'video editor', 'ffmpeg', 'podcast'] + 'video editor', 'ffmpeg', 'podcast'], packages=[ 'avpython', 'avpython.components' diff --git a/src/components/video.py b/src/components/video.py index e1f182c..9e3db30 100644 --- a/src/components/video.py +++ b/src/components/video.py @@ -45,7 +45,7 @@ class Video: '-i', self.videoPath, '-f', 'image2pipe', '-pix_fmt', 'rgba', - '-filter:v', 'scale=%s:%s' % scale( + '-filter_complex', '[0:v] scale=%s:%s' % scale( self.scale, self.width, self.height, str), '-vcodec', 'rawvideo', '-', ] @@ -272,7 +272,7 @@ class Component(Component): '-i', self.videoPath, '-f', 'image2pipe', '-pix_fmt', 'rgba', - '-filter:v', 'scale=%s:%s' % scale( + '-filter_complex', '[0:v] scale=%s:%s' % scale( self.scale, width, height, str), '-vcodec', 'rawvideo', '-', '-ss', '90', diff --git a/src/core.py b/src/core.py index 324b04f..a0a028b 100644 --- a/src/core.py +++ b/src/core.py @@ -541,6 +541,10 @@ class Core: extraInputFile, params = params ffmpegCommand.extend([ '-t', safeDuration, + # Tell ffmpeg about shorter clips (seemingly not needed) + # streamDuration = self.getAudioDuration(extraInputFile) + # if streamDuration > float(safeDuration) + # else "{0:.3f}".format(streamDuration), '-i', extraInputFile ]) # Construct dataset of extra filters we'll need to add later @@ -551,7 +555,7 @@ class Core: ffmpegFilter, params[ffmpegFilter] )) - # Start creating avfilters! + # Start creating avfilters! Popen-style, so don't use semicolons; extraFilterCommand = [] if globalFilters <= 0: diff --git a/src/mainwindow.py b/src/mainwindow.py index 76ed179..ca8e697 100644 --- a/src/mainwindow.py +++ b/src/mainwindow.py @@ -305,7 +305,12 @@ class MainWindow(QtWidgets.QMainWindow): QtWidgets.QShortcut("Ctrl+A", self.window, self.openSaveProjectDialog) QtWidgets.QShortcut("Ctrl+O", self.window, self.openOpenProjectDialog) QtWidgets.QShortcut("Ctrl+N", self.window, self.createNewProject) - QtWidgets.QShortcut("Ctrl+Alt+Shift+R", self.window, self.drawPreview) + QtWidgets.QShortcut( + "Ctrl+Alt+Shift+R", self.window, self.drawPreview + ) + QtWidgets.QShortcut( + "Ctrl+Alt+Shift+F", self.window, self.showFfmpegCommand + ) QtWidgets.QShortcut( "Ctrl+T", self.window, @@ -580,6 +585,18 @@ class MainWindow(QtWidgets.QMainWindow): def showPreviewImage(self, image): self.previewWindow.changePixmap(image) + def showFfmpegCommand(self): + from textwrap import wrap + command = self.core.createFfmpegCommand( + self.window.lineEdit_audioFile.text(), + self.window.lineEdit_outputFile.text(), + self.core.getAudioDuration(self.window.lineEdit_audioFile.text()) + ) + lines = wrap(" ".join(command), 49) + self.showMessage( + msg="Current FFmpeg command:\n\n %s" % " ".join(lines) + ) + def insertComponent(self, index): componentList = self.window.listWidget_componentList stackedWidget = self.window.stackedWidget -- cgit v1.2.3