[postprocessor/ffmpeg] added option --force-recode-video to force recoding a video
This commit is contained in:
parent
5dda1edef9
commit
f05d29c932
@ -263,6 +263,7 @@ def _real_main(argv=None):
|
||||
postprocessors.append({
|
||||
'key': 'FFmpegVideoConvertor',
|
||||
'preferedformat': opts.recodevideo,
|
||||
'force_recode': opts.force_recode_video
|
||||
})
|
||||
# FFmpegMetadataPP should be run after FFmpegVideoConvertorPP and
|
||||
# FFmpegExtractAudioPP as containers before conversion may not support
|
||||
|
@ -794,6 +794,10 @@ def parseOpts(overrideArguments=None):
|
||||
'--recode-video',
|
||||
metavar='FORMAT', dest='recodevideo', default=None,
|
||||
help='Encode the video to another format if necessary (currently supported: mp4|flv|ogg|webm|mkv|avi)')
|
||||
postproc.add_option(
|
||||
'--force-recode-video',
|
||||
action='store_true', dest='force_recode_video', default=False,
|
||||
help='Force recoding a video if it is already in the target format')
|
||||
postproc.add_option(
|
||||
'--postprocessor-args',
|
||||
dest='postprocessor_args', metavar='ARGS',
|
||||
|
@ -350,13 +350,16 @@ class FFmpegExtractAudioPP(FFmpegPostProcessor):
|
||||
|
||||
|
||||
class FFmpegVideoConvertorPP(FFmpegPostProcessor):
|
||||
def __init__(self, downloader=None, preferedformat=None):
|
||||
def __init__(self, downloader=None, preferedformat=None, force_recode=False):
|
||||
super(FFmpegVideoConvertorPP, self).__init__(downloader)
|
||||
self._preferedformat = preferedformat
|
||||
self._force_recode = force_recode
|
||||
|
||||
def run(self, information):
|
||||
path = information['filepath']
|
||||
if information['ext'] == self._preferedformat:
|
||||
if self._force_recode:
|
||||
self._downloader.to_screen('[ffmpeg] Forcing video file recoding as %s' % (self._preferedformat))
|
||||
if information['ext'] == self._preferedformat and not self._force_recode:
|
||||
self._downloader.to_screen('[ffmpeg] Not converting video file %s - already is in target format %s' % (path, self._preferedformat))
|
||||
return [], information
|
||||
options = []
|
||||
@ -364,7 +367,7 @@ class FFmpegVideoConvertorPP(FFmpegPostProcessor):
|
||||
options.extend(['-c:v', 'libxvid', '-vtag', 'XVID'])
|
||||
prefix, sep, ext = path.rpartition('.')
|
||||
outpath = prefix + sep + self._preferedformat
|
||||
self._downloader.to_screen('[' + 'ffmpeg' + '] Converting video from %s to %s, Destination: ' % (information['ext'], self._preferedformat) + outpath)
|
||||
self._downloader.to_screen('[ffmpeg] Converting video from %s to %s, Destination: ' % (information['ext'], self._preferedformat) + outpath)
|
||||
self.run_ffmpeg(path, outpath, options)
|
||||
information['filepath'] = outpath
|
||||
information['format'] = self._preferedformat
|
||||
|
Loading…
x
Reference in New Issue
Block a user