1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-11 08:37:59 +00:00

sub: allow setting lavc txt_page special values via teletext_page

* Range of accepted values for teletext_page now include 0 and -1.
 * 0 means "subtitle" and -1 means "*".
 * Make 0 the default.

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
This commit is contained in:
Mohammad AlSaleh 2024-01-14 21:20:08 +03:00 committed by sfan5
parent 09606b9db9
commit a1bda5b34d
4 changed files with 17 additions and 7 deletions

View File

@ -46,6 +46,7 @@ Interface changes
- add the command `load-input-conf`
- remove `--vo=rpi`, `--gpu-context=rpi`, and `--hwdec=mmal`
- add `auto` choice to `--deinterlace`
- change `--teletext-page` default from 100 to 0 ("subtitle" in lavc)
--- mpv 0.37.0 ---
- `--save-position-on-quit` and its associated commands now store state files
in %LOCALAPPDATA% instead of %APPDATA% directory by default on Windows.

View File

@ -2763,9 +2763,12 @@ Subtitles
of subtitles across seeks, so after a seek libass can't eliminate subtitle
packets with the same ReadOrder as earlier packets.
``--teletext-page=<1-999>``
``--teletext-page=<-1-999>``
This works for ``dvb_teletext`` subtitle streams, and if FFmpeg has been
compiled with support for it.
compiled with support for it. `-1` matches all pages. `0` (default) matches
all subtitle pages.
Default: 0
``--sub-past-video-end``
After the last frame of video, if this option is enabled, subtitles will

View File

@ -318,7 +318,7 @@ const struct m_sub_options mp_subtitle_sub_opts = {
{"sub-ass-scale-with-window", OPT_BOOL(ass_scale_with_window)},
{"sub", OPT_SUBSTRUCT(sub_style, sub_style_conf)},
{"sub-clear-on-seek", OPT_BOOL(sub_clear_on_seek)},
{"teletext-page", OPT_INT(teletext_page), M_RANGE(1, 999)},
{"teletext-page", OPT_INT(teletext_page), M_RANGE(-1, 999)},
{"sub-past-video-end", OPT_BOOL(sub_past_video_end)},
{"sub-ass-force-style", OPT_REPLACED("sub-ass-style-overrides")},
{"sub-lavc-o", OPT_KEYVALUELIST(sub_avopts)},
@ -331,7 +331,7 @@ const struct m_sub_options mp_subtitle_sub_opts = {
.sub_scale_by_window = true,
.sub_use_margins = true,
.sub_scale_with_window = true,
.teletext_page = 100,
.teletext_page = 0,
.sub_scale = 1,
.ass_vsfilter_aspect_compat = true,
.ass_vsfilter_color_compat = 1,

View File

@ -311,9 +311,15 @@ static void decode(struct sd *sd, struct demux_packet *packet)
mp_set_av_packet(priv->avpkt, packet, &priv->pkt_timebase);
if (ctx->codec_id == AV_CODEC_ID_DVB_TELETEXT) {
char page[4];
snprintf(page, sizeof(page), "%d", opts->teletext_page);
av_opt_set(ctx, "txt_page", page, AV_OPT_SEARCH_CHILDREN);
if (!opts->teletext_page) {
av_opt_set(ctx, "txt_page", "subtitle", AV_OPT_SEARCH_CHILDREN);
} else if (opts->teletext_page == -1) {
av_opt_set(ctx, "txt_page", "*", AV_OPT_SEARCH_CHILDREN);
} else {
char page[4];
snprintf(page, sizeof(page), "%d", opts->teletext_page);
av_opt_set(ctx, "txt_page", page, AV_OPT_SEARCH_CHILDREN);
}
}
int got_sub;