diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-06-21 22:53:17 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-06-21 22:56:36 +0530 |
commit | e36d50c5dd35973c090f87df05d4e94963e8036c (patch) | |
tree | be74700890c89fde704fd725ff5c43816e0ee3e3 /yt_dlp/postprocessor/ffmpeg.py | |
parent | ff0f78e1fef082b7702f3ce783381d3609415649 (diff) | |
download | hypervideo-pre-e36d50c5dd35973c090f87df05d4e94963e8036c.tar.lz hypervideo-pre-e36d50c5dd35973c090f87df05d4e94963e8036c.tar.xz hypervideo-pre-e36d50c5dd35973c090f87df05d4e94963e8036c.zip |
[websockets] Add `WebSocketFragmentFD` (#399)
Necessary for #392
Co-authored by: nao20010128nao, pukkandan
Diffstat (limited to 'yt_dlp/postprocessor/ffmpeg.py')
-rw-r--r-- | yt_dlp/postprocessor/ffmpeg.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/yt_dlp/postprocessor/ffmpeg.py b/yt_dlp/postprocessor/ffmpeg.py index 4685288a7..83714358e 100644 --- a/yt_dlp/postprocessor/ffmpeg.py +++ b/yt_dlp/postprocessor/ffmpeg.py @@ -700,6 +700,35 @@ class FFmpegFixupM3u8PP(FFmpegFixupPostProcessor): return [], info +class FFmpegFixupTimestampPP(FFmpegFixupPostProcessor): + + def __init__(self, downloader=None, trim=0.001): + # "trim" should be used when the video contains unintended packets + super(FFmpegFixupTimestampPP, self).__init__(downloader) + assert isinstance(trim, (int, float)) + self.trim = str(trim) + + @PostProcessor._restrict_to(images=False) + def run(self, info): + required_version = '4.4' + if is_outdated_version(self._versions[self.basename], required_version): + self.report_warning( + 'A re-encode is needed to fix timestamps in older versions of ffmpeg. ' + f'Please install ffmpeg {required_version} or later to fixup without re-encoding') + opts = ['-vf', 'setpts=PTS-STARTPTS'] + else: + opts = ['-c', 'copy', '-bsf', 'setts=ts=TS-STARTPTS'] + self._fixup('Fixing frame timestamp', info['filepath'], opts + ['-map', '0', '-dn', '-ss', self.trim]) + return [], info + + +class FFmpegFixupDurationPP(FFmpegFixupPostProcessor): + @PostProcessor._restrict_to(images=False) + def run(self, info): + self._fixup('Fixing video duration', info['filepath'], ['-c', 'copy', '-map', '0', '-dn']) + return [], info + + class FFmpegSubtitlesConvertorPP(FFmpegPostProcessor): SUPPORTED_EXTS = ('srt', 'vtt', 'ass', 'lrc') |