diff options
| author | tassaron | 2017-07-29 23:45:37 -0400 |
|---|---|---|
| committer | tassaron | 2017-07-29 23:45:37 -0400 |
| commit | db1ea1fc4edf19589e82171d48c417742c61c74b (patch) | |
| tree | 61058487ca96905f6f722498e0f6f2fc69dbb7c4 | |
| parent | 1297af61c9ce00b6dd76f8ec690baedf5bf887c7 (diff) | |
generic preview sound for waveform component
with secret preference to use the audio file again
| -rw-r--r-- | src/component.py | 2 | ||||
| -rw-r--r-- | src/components/waveform.py | 38 | ||||
| -rw-r--r-- | src/core.py | 1 | ||||
| -rw-r--r-- | src/mainwindow.py | 2 | ||||
| -rw-r--r-- | src/toolkit/ffmpeg.py | 14 |
5 files changed, 39 insertions, 18 deletions
diff --git a/src/component.py b/src/component.py index fc8fbd3..6d49406 100644 --- a/src/component.py +++ b/src/component.py @@ -427,7 +427,7 @@ class ComponentError(RuntimeError): ComponentError.prevErrors.insert(0, name) curTime = time.time() if name in ComponentError.prevErrors[1:] \ - and curTime - ComponentError.lastTime < 0.2: + and curTime - ComponentError.lastTime < 1.0: # Don't create multiple windows for quickly repeated messages return ComponentError.lastTime = time.time() diff --git a/src/components/waveform.py b/src/components/waveform.py index 375b3fc..b4b19e9 100644 --- a/src/components/waveform.py +++ b/src/components/waveform.py @@ -90,7 +90,7 @@ class Component(Component): width=w, height=h, chunkSize=self.chunkSize, frameRate=int(self.settings.value("outputFrameRate")), - parent=self.parent, component=self, + parent=self.parent, component=self, debug=True, ) def frameRender(self, frameNo): @@ -102,20 +102,25 @@ class Component(Component): closePipe(self.video.pipe) def getPreviewFrame(self, width, height): - inputFile = self.parent.window.lineEdit_audioFile.text() - if not inputFile or not os.path.exists(inputFile): - return - duration = getAudioDuration(inputFile) - if not duration: - return - startPt = duration / 3 + genericPreview = self.settings.value("pref_genericPreview") + startPt = 0 + if not genericPreview: + inputFile = self.parent.window.lineEdit_audioFile.text() + if not inputFile or not os.path.exists(inputFile): + return + duration = getAudioDuration(inputFile) + if not duration: + return + startPt = duration / 3 command = [ self.core.FFMPEG_BIN, '-thread_queue_size', '512', '-r', self.settings.value("outputFrameRate"), '-ss', "{0:.3f}".format(startPt), - '-i', inputFile, + '-i', + os.path.join(self.core.wd, 'background.png') + if genericPreview else inputFile, '-f', 'image2pipe', '-pix_fmt', 'rgba', ] @@ -148,13 +153,19 @@ class Component(Component): amplitude = 'cbrt' hexcolor = QColor(*self.color).name() opacity = "{0:.1f}".format(self.opacity / 100) + genericPreview = self.settings.value("pref_genericPreview") return [ '-filter_complex', - '[0:a] %s%s' + '%s%s%s' 'showwaves=r=30:s=%sx%s:mode=%s:colors=%s@%s:scale=%s%s%s [v1]; ' - '[v1] scale=%s:%s%s [v]' % ( - 'compand=gain=2,' if self.compress else '', + '[v1] scale=%s:%s%s,setpts=2.0*PTS [v]' % ( + 'aevalsrc=sin(1*2*PI*t)*sin(880*2*PI*t),' + if preview and genericPreview else '[0:a] ', + 'compand=.3|.3:1|1:-90/-60|-60/-40|-40/-30|-20/-20:6:0:-90:0.2' + ',' if self.compress and not preview else ( + 'compand=gain=5,' if self.compress else '' + ), 'aformat=channel_layouts=mono,' if self.mono else '', self.settings.value("outputWidth"), self.settings.value("outputHeight"), @@ -165,7 +176,8 @@ class Component(Component): ) if self.mode < 2 else '', ', hflip' if self.mirror else'', w, h, - ', trim=duration=%s' % "{0:.3f}".format(startPt + 1) if preview else '', + ', trim=duration=%s' % "{0:.3f}".format(startPt + 1) + if preview else '', ), '-map', '[v]', ] diff --git a/src/core.py b/src/core.py index 1c29774..24bf097 100644 --- a/src/core.py +++ b/src/core.py @@ -506,6 +506,7 @@ class Core: "outputContainer": "MP4", "projectDir": os.path.join(cls.dataDir, 'projects'), "pref_insertCompAtTop": True, + "pref_genericPreview": True, } for parm, value in defaultSettings.items(): diff --git a/src/mainwindow.py b/src/mainwindow.py index 070131c..a97081e 100644 --- a/src/mainwindow.py +++ b/src/mainwindow.py @@ -791,6 +791,8 @@ class MainWindow(QtWidgets.QMainWindow): field.blockSignals(True) field.setText('') field.blockSignals(False) + self.progressBarUpdated(0) + self.progressBarSetText('') @disableWhenEncoding def createNewProject(self, prompt=True): diff --git a/src/toolkit/ffmpeg.py b/src/toolkit/ffmpeg.py index e37282f..4ea2863 100644 --- a/src/toolkit/ffmpeg.py +++ b/src/toolkit/ffmpeg.py @@ -37,6 +37,7 @@ class FfmpegVideo: self.frameNo = -1 self.currentFrame = 'None' self.map_ = None + self.debug = False if 'loopVideo' in kwargs and kwargs['loopVideo']: self.loopValue = '-1' @@ -47,6 +48,8 @@ class FfmpegVideo: kwargs['filter_'].insert(0, '-filter_complex') else: kwargs['filter_'] = None + if 'debug' in kwargs: + self.debug = True self.command = [ core.Core.FFMPEG_BIN, @@ -62,7 +65,6 @@ class FfmpegVideo: kwargs['filter_'] ) self.command.extend([ - '-s:v', '%sx%s' % (self.width, self.height), '-codec:v', 'rawvideo', '-', ]) @@ -88,11 +90,15 @@ class FfmpegVideo: self.frameBuffer.task_done() def fillBuffer(self): - import sys - print(self.command) + if self.debug: + print(" ".join([word for word in self.command])) + err = sys.__stdout__ + else: + err = subprocess.DEVNULL + self.pipe = openPipe( self.command, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, - stderr=sys.__stdout__, bufsize=10**8 + stderr=err, bufsize=10**8 ) while True: if self.parent.canceled: |
