1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-09-04 00:55:15 +00:00

[ModifyChapters] fixes (See desc)

* [docs] Fix typo
* Do not enable `sponskrub` by default
* Fix `--force-keyframes-at-cuts`
* Don't embed subtitles if the video has been cut. Previously, running `--remove-chapters` with `--embed-subs` multiple times caused repeated cuts and out-of-sync subtitles
* Store `_real_duration` to prevent running ffprobe multiple times
This commit is contained in:
pukkandan
2021-09-04 01:37:41 +05:30
parent dd594deb2a
commit 165efb823b
3 changed files with 29 additions and 15 deletions

View File

@ -15,6 +15,7 @@ from ..utils import (
dfxp2srt,
encodeArgument,
encodeFilename,
float_or_none,
get_exe_version,
is_outdated_version,
ISO639Utils,
@ -233,6 +234,23 @@ class FFmpegPostProcessor(PostProcessor):
None)
return num, len(streams)
def _get_real_video_duration(self, info, fatal=True):
try:
if '_real_duration' not in info:
info['_real_duration'] = float_or_none(
traverse_obj(self.get_metadata_object(info['filepath']), ('format', 'duration')))
if not info['_real_duration']:
raise PostProcessingError('ffprobe returned empty duration')
except PostProcessingError as e:
if fatal:
raise PostProcessingError(f'Unable to determine video duration; {e}')
return info.setdefault('_real_duration', None)
def _duration_mismatch(self, d1, d2):
if not d1 or not d2:
return None
return abs(d1 - d2) > 1
def run_ffmpeg_multiple_files(self, input_paths, out_path, opts, **kwargs):
return self.real_run_ffmpeg(
[(path, []) for path in input_paths],
@ -528,6 +546,10 @@ class FFmpegEmbedSubtitlePP(FFmpegPostProcessor):
return [], information
filename = information['filepath']
if self._duration_mismatch(
self._get_real_video_duration(information, False), information['duration']):
self.to_screen(f'Skipping {self.pp_key()} since the real and expected durations mismatch')
return [], information
ext = information['ext']
sub_langs, sub_names, sub_filenames = [], [], []