generic preview sound for waveform component
with secret preference to use the audio file again
This commit is contained in:
parent
1297af61c9
commit
db1ea1fc4e
|
@ -427,7 +427,7 @@ class ComponentError(RuntimeError):
|
||||||
ComponentError.prevErrors.insert(0, name)
|
ComponentError.prevErrors.insert(0, name)
|
||||||
curTime = time.time()
|
curTime = time.time()
|
||||||
if name in ComponentError.prevErrors[1:] \
|
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
|
# Don't create multiple windows for quickly repeated messages
|
||||||
return
|
return
|
||||||
ComponentError.lastTime = time.time()
|
ComponentError.lastTime = time.time()
|
||||||
|
|
|
@ -90,7 +90,7 @@ class Component(Component):
|
||||||
width=w, height=h,
|
width=w, height=h,
|
||||||
chunkSize=self.chunkSize,
|
chunkSize=self.chunkSize,
|
||||||
frameRate=int(self.settings.value("outputFrameRate")),
|
frameRate=int(self.settings.value("outputFrameRate")),
|
||||||
parent=self.parent, component=self,
|
parent=self.parent, component=self, debug=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
def frameRender(self, frameNo):
|
def frameRender(self, frameNo):
|
||||||
|
@ -102,20 +102,25 @@ class Component(Component):
|
||||||
closePipe(self.video.pipe)
|
closePipe(self.video.pipe)
|
||||||
|
|
||||||
def getPreviewFrame(self, width, height):
|
def getPreviewFrame(self, width, height):
|
||||||
inputFile = self.parent.window.lineEdit_audioFile.text()
|
genericPreview = self.settings.value("pref_genericPreview")
|
||||||
if not inputFile or not os.path.exists(inputFile):
|
startPt = 0
|
||||||
return
|
if not genericPreview:
|
||||||
duration = getAudioDuration(inputFile)
|
inputFile = self.parent.window.lineEdit_audioFile.text()
|
||||||
if not duration:
|
if not inputFile or not os.path.exists(inputFile):
|
||||||
return
|
return
|
||||||
startPt = duration / 3
|
duration = getAudioDuration(inputFile)
|
||||||
|
if not duration:
|
||||||
|
return
|
||||||
|
startPt = duration / 3
|
||||||
|
|
||||||
command = [
|
command = [
|
||||||
self.core.FFMPEG_BIN,
|
self.core.FFMPEG_BIN,
|
||||||
'-thread_queue_size', '512',
|
'-thread_queue_size', '512',
|
||||||
'-r', self.settings.value("outputFrameRate"),
|
'-r', self.settings.value("outputFrameRate"),
|
||||||
'-ss', "{0:.3f}".format(startPt),
|
'-ss', "{0:.3f}".format(startPt),
|
||||||
'-i', inputFile,
|
'-i',
|
||||||
|
os.path.join(self.core.wd, 'background.png')
|
||||||
|
if genericPreview else inputFile,
|
||||||
'-f', 'image2pipe',
|
'-f', 'image2pipe',
|
||||||
'-pix_fmt', 'rgba',
|
'-pix_fmt', 'rgba',
|
||||||
]
|
]
|
||||||
|
@ -148,13 +153,19 @@ class Component(Component):
|
||||||
amplitude = 'cbrt'
|
amplitude = 'cbrt'
|
||||||
hexcolor = QColor(*self.color).name()
|
hexcolor = QColor(*self.color).name()
|
||||||
opacity = "{0:.1f}".format(self.opacity / 100)
|
opacity = "{0:.1f}".format(self.opacity / 100)
|
||||||
|
genericPreview = self.settings.value("pref_genericPreview")
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'-filter_complex',
|
'-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]; '
|
'showwaves=r=30:s=%sx%s:mode=%s:colors=%s@%s:scale=%s%s%s [v1]; '
|
||||||
'[v1] scale=%s:%s%s [v]' % (
|
'[v1] scale=%s:%s%s,setpts=2.0*PTS [v]' % (
|
||||||
'compand=gain=2,' if self.compress else '',
|
'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 '',
|
'aformat=channel_layouts=mono,' if self.mono else '',
|
||||||
self.settings.value("outputWidth"),
|
self.settings.value("outputWidth"),
|
||||||
self.settings.value("outputHeight"),
|
self.settings.value("outputHeight"),
|
||||||
|
@ -165,7 +176,8 @@ class Component(Component):
|
||||||
) if self.mode < 2 else '',
|
) if self.mode < 2 else '',
|
||||||
', hflip' if self.mirror else'',
|
', hflip' if self.mirror else'',
|
||||||
w, h,
|
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]',
|
'-map', '[v]',
|
||||||
]
|
]
|
||||||
|
|
|
@ -506,6 +506,7 @@ class Core:
|
||||||
"outputContainer": "MP4",
|
"outputContainer": "MP4",
|
||||||
"projectDir": os.path.join(cls.dataDir, 'projects'),
|
"projectDir": os.path.join(cls.dataDir, 'projects'),
|
||||||
"pref_insertCompAtTop": True,
|
"pref_insertCompAtTop": True,
|
||||||
|
"pref_genericPreview": True,
|
||||||
}
|
}
|
||||||
|
|
||||||
for parm, value in defaultSettings.items():
|
for parm, value in defaultSettings.items():
|
||||||
|
|
|
@ -791,6 +791,8 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||||
field.blockSignals(True)
|
field.blockSignals(True)
|
||||||
field.setText('')
|
field.setText('')
|
||||||
field.blockSignals(False)
|
field.blockSignals(False)
|
||||||
|
self.progressBarUpdated(0)
|
||||||
|
self.progressBarSetText('')
|
||||||
|
|
||||||
@disableWhenEncoding
|
@disableWhenEncoding
|
||||||
def createNewProject(self, prompt=True):
|
def createNewProject(self, prompt=True):
|
||||||
|
|
|
@ -37,6 +37,7 @@ class FfmpegVideo:
|
||||||
self.frameNo = -1
|
self.frameNo = -1
|
||||||
self.currentFrame = 'None'
|
self.currentFrame = 'None'
|
||||||
self.map_ = None
|
self.map_ = None
|
||||||
|
self.debug = False
|
||||||
|
|
||||||
if 'loopVideo' in kwargs and kwargs['loopVideo']:
|
if 'loopVideo' in kwargs and kwargs['loopVideo']:
|
||||||
self.loopValue = '-1'
|
self.loopValue = '-1'
|
||||||
|
@ -47,6 +48,8 @@ class FfmpegVideo:
|
||||||
kwargs['filter_'].insert(0, '-filter_complex')
|
kwargs['filter_'].insert(0, '-filter_complex')
|
||||||
else:
|
else:
|
||||||
kwargs['filter_'] = None
|
kwargs['filter_'] = None
|
||||||
|
if 'debug' in kwargs:
|
||||||
|
self.debug = True
|
||||||
|
|
||||||
self.command = [
|
self.command = [
|
||||||
core.Core.FFMPEG_BIN,
|
core.Core.FFMPEG_BIN,
|
||||||
|
@ -62,7 +65,6 @@ class FfmpegVideo:
|
||||||
kwargs['filter_']
|
kwargs['filter_']
|
||||||
)
|
)
|
||||||
self.command.extend([
|
self.command.extend([
|
||||||
'-s:v', '%sx%s' % (self.width, self.height),
|
|
||||||
'-codec:v', 'rawvideo', '-',
|
'-codec:v', 'rawvideo', '-',
|
||||||
])
|
])
|
||||||
|
|
||||||
|
@ -88,11 +90,15 @@ class FfmpegVideo:
|
||||||
self.frameBuffer.task_done()
|
self.frameBuffer.task_done()
|
||||||
|
|
||||||
def fillBuffer(self):
|
def fillBuffer(self):
|
||||||
import sys
|
if self.debug:
|
||||||
print(self.command)
|
print(" ".join([word for word in self.command]))
|
||||||
|
err = sys.__stdout__
|
||||||
|
else:
|
||||||
|
err = subprocess.DEVNULL
|
||||||
|
|
||||||
self.pipe = openPipe(
|
self.pipe = openPipe(
|
||||||
self.command, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE,
|
self.command, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE,
|
||||||
stderr=sys.__stdout__, bufsize=10**8
|
stderr=err, bufsize=10**8
|
||||||
)
|
)
|
||||||
while True:
|
while True:
|
||||||
if self.parent.canceled:
|
if self.parent.canceled:
|
||||||
|
|
Reference in New Issue