add post processor
[youtube-dl] / youtube_dl / postprocessor / ffmpeg.py
index 8c19ed7fa1fb833103c519754499a44e9bf3a76b..26a70491a084b5dd28c250eb705f47ea6bf55905 100644 (file)
@@ -479,6 +479,21 @@ class FFmpegMergerPP(FFmpegPostProcessor):
     def run(self, info):
         filename = info['filepath']
         args = ['-c', 'copy']
+        self._downloader.to_screen(u'[ffmpeg] Merging formats into "%s"' % filename)
         self.run_ffmpeg_multiple_files(info['__files_to_merge'], filename, args)
         return True, info
 
+
+class FFmpegMediaFixPP(FFmpegPostProcessor):
+    def run(self, info):
+        filename = info['filepath']
+        temp_filename = prepend_extension(filename, 'temp')
+
+        options = ['-vcodec', 'copy', '-acodec', 'copy']
+        self._downloader.to_screen(u'[ffmpeg] Fixing media file "%s"' % filename)
+        self.run_ffmpeg(filename, temp_filename, options)
+
+        os.remove(encodeFilename(filename))
+        os.rename(encodeFilename(temp_filename), encodeFilename(filename))
+
+        return True, info