From f07b74fc18aac210c60ee8b8cb29b5b43b0eb780 Mon Sep 17 00:00:00 2001 From: Philipp Hagemeister Date: Fri, 16 May 2014 15:47:54 +0200 Subject: [PATCH] [ffmpeg] Correct argument encoding on Windows with Python 2.x Fixes #2924 --- youtube_dl/postprocessor/ffmpeg.py | 3 ++- youtube_dl/utils.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/youtube_dl/postprocessor/ffmpeg.py b/youtube_dl/postprocessor/ffmpeg.py index 602e370f4..45328ed43 100644 --- a/youtube_dl/postprocessor/ffmpeg.py +++ b/youtube_dl/postprocessor/ffmpeg.py @@ -9,6 +9,7 @@ from .common import AudioConversionError, PostProcessor from ..utils import ( check_executable, compat_subprocess_get_DEVNULL, + encodeArgument, encodeFilename, PostProcessingError, prepend_extension, @@ -48,7 +49,7 @@ class FFmpegPostProcessor(PostProcessor): for path in input_paths: files_cmd.extend(['-i', encodeFilename(path, True)]) cmd = ([self._get_executable(), '-y'] + files_cmd - + opts + + + [encodeArgument(o) for o in opts] + [encodeFilename(self._ffmpeg_filename_argument(out_path), True)]) if self._downloader.params.get('verbose', False): diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index aa9347f43..b97e62ae9 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -540,6 +540,16 @@ def encodeFilename(s, for_subprocess=False): encoding = 'utf-8' return s.encode(encoding, 'ignore') + +def encodeArgument(s): + if not isinstance(s, compat_str): + # Legacy code that uses byte strings + # Uncomment the following line after fixing all post processors + #assert False, 'Internal error: %r should be of type %r, is %r' % (s, compat_str, type(s)) + s = s.decode('ascii') + return encodeFilename(s, True) + + def decodeOption(optval): if optval is None: return optval -- 2.22.2