Skip to content

avformat: set stream.type to "subtitle" for subtitle streams#1222

Closed
xevrion wants to merge 1 commit into
mltframework:masterfrom
xevrion:fix/subtitle-stream-type-metadata
Closed

avformat: set stream.type to "subtitle" for subtitle streams#1222
xevrion wants to merge 1 commit into
mltframework:masterfrom
xevrion:fix/subtitle-stream-type-metadata

Conversation

@xevrion

@xevrion xevrion commented Apr 19, 2026

Copy link
Copy Markdown

The switch statement in producer_avformat.c that sets meta.media.X.stream.type already handles AVMEDIA_TYPE_VIDEO and AVMEDIA_TYPE_AUDIO, but has no case for AVMEDIA_TYPE_SUBTITLE. This means subtitle streams in MKV files (and other containers) leave the stream.type property completely unset.

This patch adds the missing case:

case AVMEDIA_TYPE_SUBTITLE:
    mlt_properties_set(meta_media, key, "subtitle");
    break;

This makes subtitle stream detection consistent with how video and audio streams are already reported, and allows applications using MLT to reliably detect subtitle streams by checking meta.media.X.stream.type == "subtitle" instead of having to fall back to inspecting codec names.

Tested with an MKV file containing an embedded SRT subtitle stream, meta.media.2.stream.type is now correctly set to "subtitle".

The switch statement handling meta.media.X.stream.type already sets
'video' and 'audio' for their respective stream types, but had no case
for AVMEDIA_TYPE_SUBTITLE, leaving the property unset for subtitle
streams in files like MKV.

Add the missing case so subtitle streams are reported consistently
with video and audio streams.
frame_rate.den = 1001;
break;
case AVMEDIA_TYPE_SUBTITLE:
mlt_properties_set(meta_media, key, "subtitle");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not compile. It looks like you (or your AI) meant to change find_default_streams() instead of this function. I will apply your change to it and close this. With it melt -consumer xml video-with-substitles now shows, for example (good):

    <property name="meta.media.2.stream.type">subtitle</property>
    <property name="meta.media.2.codec.name">mov_text</property>
    <property name="meta.media.2.codec.long_name">3GPP Timed Text subtitle</property>
    <property name="meta.media.2.codec.bit_rate">41</property>
    <property name="meta.attr.2.stream.language.markup">eng</property>
    <property name="meta.attr.2.stream.handler_name.markup">SubtitleHandler</property>

Before it was missing <property name="meta.media.2.stream.type">subtitle</property>

ddennedy added a commit that referenced this pull request Apr 20, 2026
@ddennedy ddennedy added this to the v7.38.0 milestone Apr 20, 2026
@ddennedy ddennedy closed this Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants