added option to include audio from Video components
This commit is contained in:
parent
8811b699a9
commit
b7931572a7
|
@ -143,7 +143,6 @@ class Component(Component):
|
|||
super().update()
|
||||
|
||||
def previewRender(self, previewWorker):
|
||||
self.videoFormats = previewWorker.core.videoFormats
|
||||
width = int(previewWorker.core.settings.value('outputWidth'))
|
||||
height = int(previewWorker.core.settings.value('outputHeight'))
|
||||
self.updateChunksize(width, height)
|
||||
|
@ -156,8 +155,7 @@ class Component(Component):
|
|||
def properties(self):
|
||||
props = []
|
||||
if self.useAudio:
|
||||
# props.append('audio')
|
||||
pass
|
||||
props.append('audio')
|
||||
if self.videoPath and not os.path.exists(self.videoPath):
|
||||
props.append('error')
|
||||
return props
|
||||
|
@ -168,7 +166,7 @@ class Component(Component):
|
|||
"layer %s does not exist!" % str(self.compPos)
|
||||
|
||||
def audio(self):
|
||||
return (self.videoPath, {})
|
||||
return (self.videoPath, {'map': '-v'})
|
||||
|
||||
def preFrameRender(self, **kwargs):
|
||||
super().preFrameRender(**kwargs)
|
||||
|
@ -216,7 +214,7 @@ class Component(Component):
|
|||
imgDir = self.settings.value("componentDir", os.path.expanduser("~"))
|
||||
filename, _ = QtWidgets.QFileDialog.getOpenFileName(
|
||||
self.page, "Choose Video",
|
||||
imgDir, "Video Files (%s)" % " ".join(self.videoFormats)
|
||||
imgDir, "Video Files (%s)" % " ".join(self.core.videoFormats)
|
||||
)
|
||||
if filename:
|
||||
self.settings.setValue("componentDir", os.path.dirname(filename))
|
||||
|
|
16
src/core.py
16
src/core.py
|
@ -526,13 +526,25 @@ class Core:
|
|||
if 'audio' in comp.properties()
|
||||
]
|
||||
if extraAudio:
|
||||
for extraInputFile, params in extraAudio:
|
||||
unwantedVideoStreams = []
|
||||
for compNo, params in enumerate(extraAudio):
|
||||
extraInputFile, params = params
|
||||
ffmpegCommand.extend([
|
||||
'-i', extraInputFile
|
||||
])
|
||||
if 'map' in params and params['map'] == '-v':
|
||||
# a video stream to remove
|
||||
unwantedVideoStreams.append(compNo + 1)
|
||||
|
||||
if unwantedVideoStreams:
|
||||
ffmpegCommand.extend(['-map', '0'])
|
||||
for compNo in unwantedVideoStreams:
|
||||
ffmpegCommand.extend([
|
||||
'-map', '-%s:v' % str(compNo)
|
||||
])
|
||||
ffmpegCommand.extend([
|
||||
'-filter_complex',
|
||||
'amix=inputs=%s:duration=longest:dropout_transition=3' % str(
|
||||
'amix=inputs=%s:duration=first:dropout_transition=3' % str(
|
||||
len(extraAudio) + 1
|
||||
),
|
||||
])
|
||||
|
|
|
@ -175,8 +175,8 @@ class Worker(QtCore.QObject):
|
|||
self.staticComponents[compNo] = None
|
||||
|
||||
ffmpegCommand = self.core.createFfmpegCommand(inputFile, outputFile)
|
||||
print('###### FFMPEG COMMAND ######\n %s' % " ".join(ffmpegCommand))
|
||||
print('###### -------------- ######')
|
||||
print('###### FFMPEG COMMAND ######\n%s' % " ".join(ffmpegCommand))
|
||||
print('############################')
|
||||
self.out_pipe = openPipe(
|
||||
ffmpegCommand, stdin=sp.PIPE, stdout=sys.stdout, stderr=sys.stdout
|
||||
)
|
||||
|
|
Reference in New Issue