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)
|
||||
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()
|
||||
|
|
|
@ -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]',
|
||||
]
|
||||
|
|
|
@ -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():
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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:
|
||||
|
|
Reference in New Issue