fix ffmpeg error, if youtube-dl runs more than once with --embed-thumbnail with same...
[youtube-dl] / youtube_dl / postprocessor / ffmpeg.py
index c22f2cdc648b440f52a08cb1ba7947e02a985019..75ee87e1a2d853cf00ae00d3ea4dd55ef1145162 100644 (file)
@@ -483,3 +483,17 @@ class FFmpegMergerPP(FFmpegPostProcessor):
         self.run_ffmpeg_multiple_files(info['__files_to_merge'], filename, args)
         return True, info
 
+
+class FFmpegAudioFixPP(FFmpegPostProcessor):
+    def run(self, info):
+        filename = info['filepath']
+        temp_filename = prepend_extension(filename, 'temp')
+
+        options = ['-vn', '-acodec', 'copy']
+        self._downloader.to_screen(u'[ffmpeg] Fixing audio file "%s"' % filename)
+        self.run_ffmpeg(filename, temp_filename, options)
+
+        os.remove(encodeFilename(filename))
+        os.rename(encodeFilename(temp_filename), encodeFilename(filename))
+
+        return True, info