From e33f11706f1db39acac05aa1d27227da2dfc7527 Mon Sep 17 00:00:00 2001 From: Stephen Macke Date: Mon, 18 Jan 2021 11:46:56 -0800 Subject: [PATCH] update history and add cmdline arg to skip framerate ratio inference --- HISTORY.rst | 7 +++++++ ffsubsync/ffsubsync.py | 11 +++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 25ee631..af2231c 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -172,3 +172,10 @@ History * Add experimental section for using golden section search to find framerate ratio; * Restore ability to read stdin and write stdout after buggy permissions check; * Exceptions that occur during syncing were mistakenly suppressed; this is now fixed; + +0.4.10 (2021-01-18) +------------------- +* Reduce max_offset_seconds (improves sync in most cases); +* Filter out metadata in subtitles when extracting speech; +* Add experimental --golden-section-search over framerate ratio (off by default); +* Try to improve sync by inferring framerate ratio based on relative duration of synced vs unsynced; diff --git a/ffsubsync/ffsubsync.py b/ffsubsync/ffsubsync.py index 25502ca..1d3e5ec 100755 --- a/ffsubsync/ffsubsync.py +++ b/ffsubsync/ffsubsync.py @@ -116,10 +116,11 @@ def try_sync(args, reference_pipe, result): continue else: srt_pipe.fit(srtin) - inferred_framerate_ratio_from_length = float(reference_pipe[-1].num_frames) / srt_pipes[0][-1].num_frames - logger.info('inferred frameratio ratio: %.3f' % inferred_framerate_ratio_from_length) - srt_pipes.append(srt_pipe_maker(inferred_framerate_ratio_from_length).fit(srtin)) - logger.info('...done') + if not args.skip_infer_framerate_ratio: + inferred_framerate_ratio_from_length = float(reference_pipe[-1].num_frames) / srt_pipes[0][-1].num_frames + logger.info('inferred frameratio ratio: %.3f' % inferred_framerate_ratio_from_length) + srt_pipes.append(srt_pipe_maker(inferred_framerate_ratio_from_length).fit(srtin)) + logger.info('...done') logger.info('computing alignments...') if args.skip_sync: best_score = 0. @@ -389,6 +390,8 @@ def add_cli_only_args(parser): '(default=%d seconds).' % DEFAULT_APPLY_OFFSET_SECONDS) parser.add_argument('--frame-rate', type=int, default=DEFAULT_FRAME_RATE, help='Frame rate for audio extraction (default=%d).' % DEFAULT_FRAME_RATE) + parser.add_argument('--skip-infer-framerate-ratio', action='store_true', + help='If set, do not try to infer framerate ratio based on duration ratio.') parser.add_argument('--output-encoding', default='utf-8', help='What encoding to use for writing output subtitles ' '(default=utf-8). Can indicate "same" to use same '