1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-12-22 16:57:40 +00:00

[ffmpeg] Correct argument encoding on Windows with Python 2.x

Fixes #2924
This commit is contained in:
Philipp Hagemeister 2014-05-16 15:47:54 +02:00
parent beee53de06
commit f07b74fc18
2 changed files with 12 additions and 1 deletions

View file

@ -9,6 +9,7 @@ from .common import AudioConversionError, PostProcessor
from ..utils import ( from ..utils import (
check_executable, check_executable,
compat_subprocess_get_DEVNULL, compat_subprocess_get_DEVNULL,
encodeArgument,
encodeFilename, encodeFilename,
PostProcessingError, PostProcessingError,
prepend_extension, prepend_extension,
@ -48,7 +49,7 @@ class FFmpegPostProcessor(PostProcessor):
for path in input_paths: for path in input_paths:
files_cmd.extend(['-i', encodeFilename(path, True)]) files_cmd.extend(['-i', encodeFilename(path, True)])
cmd = ([self._get_executable(), '-y'] + files_cmd cmd = ([self._get_executable(), '-y'] + files_cmd
+ opts + + [encodeArgument(o) for o in opts] +
[encodeFilename(self._ffmpeg_filename_argument(out_path), True)]) [encodeFilename(self._ffmpeg_filename_argument(out_path), True)])
if self._downloader.params.get('verbose', False): if self._downloader.params.get('verbose', False):

View file

@ -540,6 +540,16 @@ def encodeFilename(s, for_subprocess=False):
encoding = 'utf-8' encoding = 'utf-8'
return s.encode(encoding, 'ignore') 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): def decodeOption(optval):
if optval is None: if optval is None:
return optval return optval