From 86965b90cd26fcd5827b998e1a74efba4cdc04af Mon Sep 17 00:00:00 2001 From: Martinez Date: Fri, 18 Mar 2016 00:02:41 +0100 Subject: [PATCH] add --ffmpeg-map, an interface to ffmpeg's -map --- over-video.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/over-video.py b/over-video.py index 4e9592b..6ece84c 100755 --- a/over-video.py +++ b/over-video.py @@ -24,7 +24,7 @@ X264_BANNED_PIXFMTS = {'bgr24'} command = over.core.types.ndict() command.identify = Command('ffprobe', '-v', 'quiet', '-print_format', 'json', '-show_format', '-show_streams', 'INFILE') command.normalize_prepass = Command('ffmpeg', '-i', 'INFILE', '-filter:a', 'volumedetect', '-f', 'null', '/dev/null') -command.encode_generic = Command('ffmpeg', '-i', 'INFILE', 'VIDEO', 'AUDIO', '-sn', 'OUTFILE') +command.encode_generic = Command('ffmpeg', '-i', 'INFILE', 'MAP', 'VIDEO', 'AUDIO', '-sn', 'OUTFILE') command.sub_vorbis = Command('-codec:a', 'libvorbis', '-qscale:a', 'QUALITY', 'NORMALIZE') command.sub_pcm = Command('-codec:a', 'pcm_s16le', 'NORMALIZE') command.sub_theora = Command('-codec:v', 'libtheora', '-qscale:v', 'QUALITY', 'VFILTER') @@ -49,7 +49,8 @@ if __name__ == '__main__': main.add_option('normalize', 'bool', True, 'Normalize the audio track.', short_name='n') main.add_option('normalize-target', 'float', -20.0, 'Target mean volume to target.') main.add_option('normalize-override', 'float', 0.0, 'Volume correction to use instead of computing the required value in a (lengthy) pre-pass.', short_name='N', use_cfg_file=False) - main.add_option('ffmpeg-vfilter', 'str', '', 'Raw ffmpeg -filter:v options, e.g. "§mscale=1280:trunc(ow/a/2)*2,transpose=dir=1§/"', short_name='f') + main.add_option('ffmpeg-vfilter', 'str', '', 'Raw ffmpeg -filter:v options, e.g. "§mscale=1280:trunc(ow/a/2)*2,transpose=dir=1§/"', short_name='F') + main.add_option('ffmpeg-map', 'str', [], 'Raw ffmpeg -map options, e.g. "§m0:1 0:2§/". This is a drop-in fix until we get proper stream selection.', short_name='M', plural=True) main.add_option('move-source', 'str', 'processed', 'Move source file to this directory after conversion. Use an empty string to disable.', short_name='m') main.add_option('dump-commands', 'bool', False, 'Print ffmpeg commands that would be executed. If §B--§gnormalize§/ is in effect, the normalization pre-pass will still be performed so that the proper volume correction can be computed.', short_name='D') main.add_option('probe', 'bool', False, 'Print the raw JSON output of ffprobe and exit.', short_name='p') @@ -68,7 +69,7 @@ if __name__ == '__main__': files.container = 'mkv' if main.cfg.context: - update_cfg_context(main, ["armed", "probe", "dump-commands"]) + update_cfg_context(main, ["armed", "probe", "dump-commands", "ffmpeg-map"]) if main.cfg.audio in ('copy', 'drop'): audio_words.append('§c%s§/' %(main.cfg.audio)) @@ -316,6 +317,17 @@ if __name__ == '__main__': else: info.vfilter_command = None + if main.cfg.ffmpeg_map: + info.map_command = [] + + for m in main.cfg.ffmpeg_map: + info.map_command.append("-map") + info.map_command.append(m) + else: + info.map_command = None + + encode_cmd.MAP = info.map_command + if main.cfg.video == 'copy': encode_cmd.VIDEO = command.sub_copy_video elif main.cfg.video == 'drop':