From b6b45d12702f18f041acf65b0d5e34714835ecb4 Mon Sep 17 00:00:00 2001 From: tassaron Date: Sun, 30 Jul 2017 13:04:02 -0400 Subject: added Spectrum component with many options tweaked Waveform, added some ffmpeg logging, made generic widget functions --- src/components/waveform.py | 48 +++++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 15 deletions(-) (limited to 'src/components/waveform.py') diff --git a/src/components/waveform.py b/src/components/waveform.py index b4b19e9..6c5133d 100644 --- a/src/components/waveform.py +++ b/src/components/waveform.py @@ -8,7 +8,9 @@ import subprocess from component import Component from toolkit.frame import BlankFrame, scale from toolkit import checkOutput, rgbFromString, pickColor -from toolkit.ffmpeg import openPipe, closePipe, getAudioDuration, FfmpegVideo +from toolkit.ffmpeg import ( + openPipe, closePipe, getAudioDuration, FfmpegVideo, exampleSound +) class Component(Component): @@ -112,6 +114,8 @@ class Component(Component): if not duration: return startPt = duration / 3 + if startPt + 3 > duration: + startPt += startPt - 3 command = [ self.core.FFMPEG_BIN, @@ -154,29 +158,43 @@ class Component(Component): hexcolor = QColor(*self.color).name() opacity = "{0:.1f}".format(self.opacity / 100) genericPreview = self.settings.value("pref_genericPreview") + if self.mode < 3: + filter_ = 'showwaves=r=%s:s=%sx%s:mode=%s:colors=%s@%s:scale=%s' % ( + self.settings.value("outputFrameRate"), + self.settings.value("outputWidth"), + self.settings.value("outputHeight"), + self.page.comboBox_mode.currentText().lower() + if self.mode != 3 else 'p2p', + hexcolor, opacity, amplitude, + ) + elif self.mode > 2: + filter_ = ( + 'showfreqs=s=%sx%s:mode=%s:colors=%s@%s' + ':ascale=%s:fscale=%s' % ( + self.settings.value("outputWidth"), + self.settings.value("outputHeight"), + 'line' if self.mode == 4 else 'bar', + hexcolor, opacity, amplitude, + 'log' if self.mono else 'lin' + ) + ) return [ '-filter_complex', '%s%s%s' - 'showwaves=r=30:s=%sx%s:mode=%s:colors=%s@%s:scale=%s%s%s [v1]; ' - '[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"), - str(self.page.comboBox_mode.currentText()).lower(), - hexcolor, opacity, amplitude, + '%s%s%s [v1]; ' + '[v1] scale=%s:%s%s [v]' % ( + exampleSound() if preview and genericPreview else '[0:a] ', + 'compand=gain=4,' if self.compress else '', + 'aformat=channel_layouts=mono,' + if self.mono and self.mode < 3 else '', + filter_, ', drawbox=x=(iw-w)/2:y=(ih-h)/2:w=iw:h=4:color=%s@%s' % ( hexcolor, opacity ) if self.mode < 2 else '', ', hflip' if self.mirror else'', w, h, - ', trim=duration=%s' % "{0:.3f}".format(startPt + 1) + ', trim=duration=%s' % "{0:.3f}".format(startPt + 3) if preview else '', ), '-map', '[v]', -- cgit v1.2.3