added option to include audio from Video components

This commit is contained in:
tassaron 2017-07-13 14:46:22 -04:00
parent 8811b699a9
commit b7931572a7
3 changed files with 19 additions and 9 deletions

View File

@ -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))

View File

@ -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
),
])

View File

@ -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
)