move code into a new function for future expansion
This commit is contained in:
parent
ae2af28808
commit
6f8f178778
|
@ -98,20 +98,53 @@ def createFfmpegCommand(inputFile, outputFile, components, duration=-1):
|
|||
'-i', inputFile
|
||||
]
|
||||
|
||||
# Add extra audio inputs and any needed avfilters
|
||||
# NOTE: Global filters are currently hard-coded here for debugging use
|
||||
globalFilters = 0 # increase to add global filters
|
||||
extraAudio = [
|
||||
comp.audio for comp in components
|
||||
if 'audio' in comp.properties()
|
||||
]
|
||||
if extraAudio or globalFilters > 0:
|
||||
segment = createAudioFilterCommand(extraAudio, safeDuration)
|
||||
ffmpegCommand.extend(segment)
|
||||
if segment:
|
||||
# Only map audio from the filters, and video from the pipe
|
||||
ffmpegCommand.extend([
|
||||
'-map', '0:v',
|
||||
'-map', '[a]',
|
||||
])
|
||||
|
||||
ffmpegCommand.extend([
|
||||
# OUTPUT
|
||||
'-vcodec', vencoder,
|
||||
'-acodec', aencoder,
|
||||
'-b:v', vbitrate,
|
||||
'-b:a', abitrate,
|
||||
'-pix_fmt', Core.settings.value('outputVideoFormat'),
|
||||
'-preset', Core.settings.value('outputPreset'),
|
||||
'-f', container
|
||||
])
|
||||
|
||||
if acodec == 'aac':
|
||||
ffmpegCommand.append('-strict')
|
||||
ffmpegCommand.append('-2')
|
||||
|
||||
ffmpegCommand.append(outputFile)
|
||||
return ffmpegCommand
|
||||
|
||||
|
||||
def createAudioFilterCommand(extraAudio, duration):
|
||||
'''Add extra inputs and any needed filters to the main ffmpeg command.'''
|
||||
# NOTE: Global filters are currently hard-coded here for debugging use
|
||||
globalFilters = 0 # increase to add global filters
|
||||
|
||||
if not extraAudio and not globalFilters:
|
||||
return []
|
||||
|
||||
ffmpegCommand = []
|
||||
# Add -i options for extra input files
|
||||
extraFilters = {}
|
||||
for streamNo, params in enumerate(reversed(extraAudio)):
|
||||
extraInputFile, params = params
|
||||
ffmpegCommand.extend([
|
||||
'-t', safeDuration,
|
||||
'-t', duration,
|
||||
# Tell ffmpeg about shorter clips (seemingly not needed)
|
||||
# streamDuration = getAudioDuration(extraInputFile)
|
||||
# if streamDuration and streamDuration > float(safeDuration)
|
||||
|
@ -188,29 +221,6 @@ def createFfmpegCommand(inputFile, outputFile, components, duration=-1):
|
|||
str(len(extraAudio) + 1)
|
||||
),
|
||||
])
|
||||
|
||||
# Only map audio from the filters, and video from the pipe
|
||||
ffmpegCommand.extend([
|
||||
'-map', '0:v',
|
||||
'-map', '[a]',
|
||||
])
|
||||
|
||||
ffmpegCommand.extend([
|
||||
# OUTPUT
|
||||
'-vcodec', vencoder,
|
||||
'-acodec', aencoder,
|
||||
'-b:v', vbitrate,
|
||||
'-b:a', abitrate,
|
||||
'-pix_fmt', Core.settings.value('outputVideoFormat'),
|
||||
'-preset', Core.settings.value('outputPreset'),
|
||||
'-f', container
|
||||
])
|
||||
|
||||
if acodec == 'aac':
|
||||
ffmpegCommand.append('-strict')
|
||||
ffmpegCommand.append('-2')
|
||||
|
||||
ffmpegCommand.append(outputFile)
|
||||
return ffmpegCommand
|
||||
|
||||
|
||||
|
|
Reference in New Issue