From d120e9013f8dbab7e82fe1878e9b5e5e9bb94e88 Mon Sep 17 00:00:00 2001 From: Andrei Troie Date: Fri, 9 Jan 2015 22:03:56 +0000 Subject: [PATCH 1/3] Added an option to specify an output format for merges when downloading separate video & audio --- youtube_dl/options.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/youtube_dl/options.py b/youtube_dl/options.py index feaca03a3..0ed5e3db4 100644 --- a/youtube_dl/options.py +++ b/youtube_dl/options.py @@ -302,6 +302,12 @@ def parseOpts(overrideArguments=None): '--youtube-skip-dash-manifest', action='store_false', dest='youtube_include_dash_manifest', help='Do not download the DASH manifest on YouTube videos') + video_format.add_option( + '--merge-output-format', + action='store', dest='merge_output_format', metavar='FORMAT' ,default=None, + help=( + 'If a merge is required (e.g. bestvideo+bestaudio), output to given container format (e.g. mkv, mp4, ogg, webm, flv) ' + 'Ignored if no merge is required')) subtitles = optparse.OptionGroup(parser, 'Subtitle Options') subtitles.add_option( From 34c781a24d1cc9b424ddc3ab3c4c616f49642c6a Mon Sep 17 00:00:00 2001 From: Andrei Troie Date: Sat, 10 Jan 2015 00:03:11 +0000 Subject: [PATCH 2/3] Passing the option into the main program's arguments --- youtube_dl/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index 844992d8e..b4ae35a2b 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -166,6 +166,9 @@ def _real_main(argv=None): if opts.recodevideo is not None: if opts.recodevideo not in ['mp4', 'flv', 'webm', 'ogg', 'mkv']: parser.error('invalid video recode format specified') + if opts.merge_output_format is not None and not '+' in opts.format: #if merge format output is used on videos that don't require merging, ignore + opts.merge_output_format = None + if opts.date is not None: date = DateRange.day(opts.date) else: @@ -323,6 +326,7 @@ def _real_main(argv=None): 'encoding': opts.encoding, 'exec_cmd': opts.exec_cmd, 'extract_flat': opts.extract_flat, + 'merge_output_format': opts.merge_output_format, 'postprocessors': postprocessors, } From d02115f83727ae0d4f394073235dc97086c64266 Mon Sep 17 00:00:00 2001 From: Andrei Troie Date: Sat, 10 Jan 2015 00:29:06 +0000 Subject: [PATCH 3/3] Use the option in preparing the merge output filename --- youtube_dl/YoutubeDL.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 24d6c2de7..6d5c401df 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -912,7 +912,7 @@ class YoutubeDL(object): selected_format = { 'requested_formats': formats_info, 'format': rf, - 'ext': formats_info[0]['ext'], + 'ext': self.params['merge_output_format'] if self.params['merge_output_format'] is not None else formats_info[0]['ext'], } else: selected_format = None