From 036fae317c9f8a2c2845f7b710ba873d02103c54 Mon Sep 17 00:00:00 2001 From: Thomas Hebb Date: Mon, 14 Jul 2025 01:26:43 -0400 Subject: [PATCH] sub/lavc_conv: prevent corruption after switching WebM WebVTT subs WebVTT subtitles in WebM require special logic, and we signal that using the "webvtt-webm" codec name, which is not part of FFmpeg. That worked fine until commit 94859997b835 ("sub: update codec info") added a call to mp_codec_info_from_av(), which overwrites our codec name with FFmpeg's the first time the subtitle decoder is initialized. As a result, WebM WebVTT subtitles are currently not rendered correctly after switching subtitle tracks. Fix the issue by resetting the codec name after calling mp_codec_info_from_av(). --- sub/lavc_conv.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sub/lavc_conv.c b/sub/lavc_conv.c index 7570dd9387..da21033992 100644 --- a/sub/lavc_conv.c +++ b/sub/lavc_conv.c @@ -104,6 +104,8 @@ struct lavc_conv *lavc_conv_create(struct sd *sd) priv->extradata = talloc_strndup(priv, avctx->subtitle_header, avctx->subtitle_header_size); mp_codec_info_from_av(avctx, sd->codec); + // Keep original codec name, which get_lavc_format() may have transformed + sd->codec->codec = priv->codec; return priv; error: