better aevalsrc inputs for spectrum previews
This commit is contained in:
parent
bed07479f1
commit
ea1a422cc5
|
@ -19,7 +19,7 @@ log = logging.getLogger('AVP.Components.Spectrum')
|
||||||
|
|
||||||
class Component(Component):
|
class Component(Component):
|
||||||
name = 'Spectrum'
|
name = 'Spectrum'
|
||||||
version = '1.0.0'
|
version = '1.0.1'
|
||||||
|
|
||||||
def widget(self, *args):
|
def widget(self, *args):
|
||||||
self.previewFrame = None
|
self.previewFrame = None
|
||||||
|
@ -65,8 +65,17 @@ class Component(Component):
|
||||||
self.changedOptions = True
|
self.changedOptions = True
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
self.page.stackedWidget.setCurrentIndex(
|
filterType = self.page.comboBox_filterType.currentIndex()
|
||||||
self.page.comboBox_filterType.currentIndex())
|
self.page.stackedWidget.setCurrentIndex(filterType)
|
||||||
|
if filterType == 3:
|
||||||
|
self.page.spinBox_hue.setEnabled(False)
|
||||||
|
else:
|
||||||
|
self.page.spinBox_hue.setEnabled(True)
|
||||||
|
if filterType == 2 or filterType == 4:
|
||||||
|
self.page.checkBox_mono.setEnabled(False)
|
||||||
|
else:
|
||||||
|
self.page.checkBox_mono.setEnabled(True)
|
||||||
|
|
||||||
super().update()
|
super().update()
|
||||||
|
|
||||||
def previewRender(self):
|
def previewRender(self):
|
||||||
|
@ -81,6 +90,8 @@ class Component(Component):
|
||||||
frame = self.getPreviewFrame()
|
frame = self.getPreviewFrame()
|
||||||
self.changedOptions = False
|
self.changedOptions = False
|
||||||
if not frame:
|
if not frame:
|
||||||
|
log.warning(
|
||||||
|
'Spectrum #%s failed to create a preview frame' % self.compPos)
|
||||||
self.previewFrame = None
|
self.previewFrame = None
|
||||||
return BlankFrame(self.width, self.height)
|
return BlankFrame(self.width, self.height)
|
||||||
else:
|
else:
|
||||||
|
@ -244,13 +255,21 @@ class Component(Component):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if self.filterType < 2:
|
||||||
|
exampleSnd = exampleSound('freq')
|
||||||
|
elif self.filterType == 2 or self.filterType == 4:
|
||||||
|
exampleSnd = exampleSound('stereo')
|
||||||
|
elif self.filterType == 3:
|
||||||
|
exampleSnd = exampleSound('white')
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'-filter_complex',
|
'-filter_complex',
|
||||||
'%s%s%s%s [v1]; '
|
'%s%s%s%s [v1]; '
|
||||||
'[v1] %s%s%s%s%s [v]' % (
|
'[v1] %s%s%s%s%s [v]' % (
|
||||||
exampleSound() if preview and genericPreview else '[0:a] ',
|
exampleSnd if preview and genericPreview else '[0:a] ',
|
||||||
'compand=gain=4,' if self.compress else '',
|
'compand=gain=4,' if self.compress else '',
|
||||||
'aformat=channel_layouts=mono,' if self.mono else '',
|
'aformat=channel_layouts=mono,'
|
||||||
|
if self.mono and self.filterType not in (2, 4) else '',
|
||||||
filter_,
|
filter_,
|
||||||
'hflip, ' if self.mirror else '',
|
'hflip, ' if self.mirror else '',
|
||||||
'trim=start=%s:end=%s, ' % (
|
'trim=start=%s:end=%s, ' % (
|
||||||
|
@ -259,7 +278,8 @@ class Component(Component):
|
||||||
) if preview else '',
|
) if preview else '',
|
||||||
'scale=%sx%s' % scale(
|
'scale=%sx%s' % scale(
|
||||||
self.scale, self.width, self.height, str),
|
self.scale, self.width, self.height, str),
|
||||||
', hue=h=%s:s=10' % str(self.hue) if self.hue > 0 else '',
|
', hue=h=%s:s=10' % str(self.hue)
|
||||||
|
if self.hue > 0 and self.filterType != 3 else '',
|
||||||
', convolution=-2 -1 0 -1 1 1 0 1 2:-2 -1 0 -1 1 1 0 1 2:-2 '
|
', convolution=-2 -1 0 -1 1 1 0 1 2:-2 -1 0 -1 1 1 0 1 2:-2 '
|
||||||
'-1 0 -1 1 1 0 1 2:-2 -1 0 -1 1 1 0 1 2'
|
'-1 0 -1 1 1 0 1 2:-2 -1 0 -1 1 1 0 1 2'
|
||||||
if self.filterType == 3 else ''
|
if self.filterType == 3 else ''
|
||||||
|
|
|
@ -140,13 +140,16 @@ class Component(Component):
|
||||||
opacity = "{0:.1f}".format(self.opacity / 100)
|
opacity = "{0:.1f}".format(self.opacity / 100)
|
||||||
genericPreview = self.settings.value("pref_genericPreview")
|
genericPreview = self.settings.value("pref_genericPreview")
|
||||||
if self.mode < 3:
|
if self.mode < 3:
|
||||||
filter_ = 'showwaves=r=%s:s=%sx%s:mode=%s:colors=%s@%s:scale=%s' % (
|
filter_ = (
|
||||||
self.settings.value("outputFrameRate"),
|
'showwaves='
|
||||||
self.settings.value("outputWidth"),
|
'r=%s:s=%sx%s:mode=%s:colors=%s@%s:scale=%s' % (
|
||||||
self.settings.value("outputHeight"),
|
self.settings.value("outputFrameRate"),
|
||||||
self.page.comboBox_mode.currentText().lower()
|
self.settings.value("outputWidth"),
|
||||||
if self.mode != 3 else 'p2p',
|
self.settings.value("outputHeight"),
|
||||||
hexcolor, opacity, amplitude,
|
self.page.comboBox_mode.currentText().lower()
|
||||||
|
if self.mode != 3 else 'p2p',
|
||||||
|
hexcolor, opacity, amplitude,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
elif self.mode > 2:
|
elif self.mode > 2:
|
||||||
filter_ = (
|
filter_ = (
|
||||||
|
@ -160,18 +163,20 @@ class Component(Component):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
baselineHeight = int(self.height * (4 / 1080))
|
||||||
return [
|
return [
|
||||||
'-filter_complex',
|
'-filter_complex',
|
||||||
'%s%s%s'
|
'%s%s%s'
|
||||||
'%s%s%s [v1]; '
|
'%s%s%s [v1]; '
|
||||||
'[v1] scale=%s:%s%s [v]' % (
|
'[v1] scale=%s:%s%s [v]' % (
|
||||||
exampleSound() if preview and genericPreview else '[0:a] ',
|
exampleSound('wave', extra='')
|
||||||
|
if preview and genericPreview else '[0:a] ',
|
||||||
'compand=gain=4,' if self.compress else '',
|
'compand=gain=4,' if self.compress else '',
|
||||||
'aformat=channel_layouts=mono,'
|
'aformat=channel_layouts=mono,'
|
||||||
if self.mono and self.mode < 3 else '',
|
if self.mono and self.mode < 3 else '',
|
||||||
filter_,
|
filter_,
|
||||||
', drawbox=x=(iw-w)/2:y=(ih-h)/2:w=iw:h=4:color=%s@%s' % (
|
', drawbox=x=(iw-w)/2:y=(ih-h)/2:w=iw:h=%s:color=%s@%s' % (
|
||||||
hexcolor, opacity
|
baselineHeight, hexcolor, opacity,
|
||||||
) if self.mode < 2 else '',
|
) if self.mode < 2 else '',
|
||||||
', hflip' if self.mirror else'',
|
', hflip' if self.mirror else'',
|
||||||
w, h,
|
w, h,
|
||||||
|
|
|
@ -457,8 +457,17 @@ def readAudioFile(filename, videoWorker):
|
||||||
return (completeAudioArray, duration)
|
return (completeAudioArray, duration)
|
||||||
|
|
||||||
|
|
||||||
def exampleSound():
|
def exampleSound(
|
||||||
return (
|
style='white', extra='apulsator=offset_l=0.35:offset_r=0.67'):
|
||||||
'aevalsrc=tan(random(1)*PI*t)*sin(random(0)*2*PI*t),'
|
'''Help generate an example sound for use in creating a preview'''
|
||||||
'apulsator=offset_l=0.5:offset_r=0.5,'
|
|
||||||
)
|
if style == 'white':
|
||||||
|
src = '-2+random(0)'
|
||||||
|
elif style == 'freq':
|
||||||
|
src = 'sin(1000*t*PI*t)'
|
||||||
|
elif style == 'wave':
|
||||||
|
src = 'sin(random(0)*2*PI*t)*tan(random(0)*2*PI*t)'
|
||||||
|
elif style == 'stereo':
|
||||||
|
src = '0.1*sin(2*PI*(360-2.5/2)*t) : 0.1*sin(2*PI*(360+2.5/2)*t)'
|
||||||
|
|
||||||
|
return "aevalsrc='%s', %s%s" % (src, extra, ', ' if extra else '')
|
||||||
|
|
Reference in New Issue