sub: add auto option to --sub-fix-timing

Third try is the charm? I stupidly missed that this option already
existed in my previous commits. Instead, add an auto value to it and
enable it by default for sd_lavc but not sd_ass. On my limited samples,
it seems to fix the gaps issue that can occur but without regressing
some duration timings for sub_lavc subtitles. Well hopefully anyway.
Fixes #12327.
This commit is contained in:
Dudemanguy 2023-09-06 21:35:22 -05:00
parent a7185fbb60
commit b47a58516a
5 changed files with 9 additions and 5 deletions

View File

@ -56,6 +56,7 @@ Interface changes
- add `--video-crop` - add `--video-crop`
- add `video-params/crop-[w,h,x,y]` - add `video-params/crop-[w,h,x,y]`
- remove `--tone-mapping-mode` - remove `--tone-mapping-mode`
- add `auto` to `--sub-fix-timing` and make it the default
--- mpv 0.36.0 --- --- mpv 0.36.0 ---
- add `--target-contrast` - add `--target-contrast`
- Target luminance value is now also applied when ICC profile is used. - Target luminance value is now also applied when ICC profile is used.

View File

@ -2627,10 +2627,11 @@ Subtitles
particular subtitles in mkv files) are always assumed to be UTF-8. particular subtitles in mkv files) are always assumed to be UTF-8.
``--sub-fix-timing=<yes|no>`` ``--sub-fix-timing=<auto|yes|no>``
Adjust subtitle timing is to remove minor gaps or overlaps between Adjust subtitle timing is to remove minor gaps or overlaps between
subtitles (if the difference is smaller than 210 ms, the gap or overlap subtitles (if the difference is smaller than 210 ms, the gap or overlap
is removed). is removed). The ``auto`` value enables this for non-text subtitles such
as PGS or DVD (default: ``auto``).
``--sub-forced-events-only=<yes|no>`` ``--sub-forced-events-only=<yes|no>``
Enabling this displays only forced events within subtitle streams. Only Enabling this displays only forced events within subtitle streams. Only

View File

@ -267,7 +267,8 @@ const struct m_sub_options mp_subtitle_sub_opts = {
{"stretch-dvd-subs", OPT_BOOL(stretch_dvd_subs)}, {"stretch-dvd-subs", OPT_BOOL(stretch_dvd_subs)},
{"stretch-image-subs-to-screen", OPT_BOOL(stretch_image_subs)}, {"stretch-image-subs-to-screen", OPT_BOOL(stretch_image_subs)},
{"image-subs-video-resolution", OPT_BOOL(image_subs_video_res)}, {"image-subs-video-resolution", OPT_BOOL(image_subs_video_res)},
{"sub-fix-timing", OPT_BOOL(sub_fix_timing)}, {"sub-fix-timing", OPT_CHOICE(sub_fix_timing,
{"auto", -1}, {"no", 0}, {"yes", 1})},
{"sub-pos", OPT_FLOAT(sub_pos), M_RANGE(0.0, 150.0)}, {"sub-pos", OPT_FLOAT(sub_pos), M_RANGE(0.0, 150.0)},
{"sub-gauss", OPT_FLOAT(sub_gauss), M_RANGE(0.0, 3.0)}, {"sub-gauss", OPT_FLOAT(sub_gauss), M_RANGE(0.0, 3.0)},
{"sub-gray", OPT_BOOL(sub_gray)}, {"sub-gray", OPT_BOOL(sub_gray)},
@ -306,6 +307,7 @@ const struct m_sub_options mp_subtitle_sub_opts = {
.defaults = &(OPT_BASE_STRUCT){ .defaults = &(OPT_BASE_STRUCT){
.sub_visibility = true, .sub_visibility = true,
.sec_sub_visibility = true, .sec_sub_visibility = true,
.sub_fix_timing = -1,
.sub_pos = 100, .sub_pos = 100,
.sub_speed = 1.0, .sub_speed = 1.0,
.ass_enabled = true, .ass_enabled = true,

View File

@ -89,7 +89,7 @@ struct mp_subtitle_opts {
bool stretch_dvd_subs; bool stretch_dvd_subs;
bool stretch_image_subs; bool stretch_image_subs;
bool image_subs_video_res; bool image_subs_video_res;
bool sub_fix_timing; int sub_fix_timing;
bool sub_scale_by_window; bool sub_scale_by_window;
bool sub_scale_with_window; bool sub_scale_with_window;
bool ass_scale_with_window; bool ass_scale_with_window;

View File

@ -498,7 +498,7 @@ static long long find_timestamp(struct sd *sd, double pts)
long long ts = llrint(pts * 1000); long long ts = llrint(pts * 1000);
if (!sd->opts->sub_fix_timing || sd->opts->ass_style_override == 0) if (sd->opts->sub_fix_timing != 1 || sd->opts->ass_style_override == 0)
return ts; return ts;
// Try to fix small gaps and overlaps. // Try to fix small gaps and overlaps.