FFmpegMetadataPP; Write temporary file to `something.temp.{ext}` (fixes #2079)
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Fri, 3 Jan 2014 11:52:27 +0000 (12:52 +0100)
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Fri, 3 Jan 2014 11:54:19 +0000 (12:54 +0100)
ffmpeg correctly recognize the formats of extensions like m4a, but it doesn’t works if it’s passed with the `—format` option.

youtube_dl/PostProcessor.py
youtube_dl/utils.py

index 69aedf87a44c72060e2af135cd95f6f820e9ab0c..097e1a9e41e67219d4205e8966d311646c9d378f 100644 (file)
@@ -10,6 +10,7 @@ from .utils import (
     PostProcessingError,
     shell_quote,
     subtitles_filename,
+    prepend_extension,
 )
 
 
@@ -496,13 +497,11 @@ class FFmpegMetadataPP(FFmpegPostProcessor):
             return True, info
 
         filename = info['filepath']
-        ext = os.path.splitext(filename)[1][1:]
-        temp_filename = filename + u'.temp'
+        temp_filename = prepend_extension(filename, 'temp')
 
         options = ['-c', 'copy']
         for (name, value) in metadata.items():
             options.extend(['-metadata', '%s=%s' % (name, value)])
-        options.extend(['-f', ext])
 
         self._downloader.to_screen(u'[ffmpeg] Adding metadata to \'%s\'' % filename)
         self.run_ffmpeg(filename, temp_filename, options)
index da5143c8ef50eb936abc4a7de98c33f7aa10c5b5..fc10fba6327ae17223431da24aae80e341712df3 100644 (file)
@@ -1119,3 +1119,8 @@ def parse_duration(s):
         if m.group('hours'):
             res += int(m.group('hours')) * 60 * 60
     return res
+
+
+def prepend_extension(filename, ext):
+    name, real_ext = os.path.splitext(filename) 
+    return u'{0}.{1}{2}'.format(name, ext, real_ext)