[FFmpeg-user] proper metadata key=value for default/nondefault subtitles

Jim Worrall coniophora at gmail.com
Wed Oct 31 14:51:28 CET 2012


On Tue, Oct 30, 2012 at 10:24 AM, Jim <coniophora at gmail.com> wrote:

>
>
> On Tue, Oct 30, 2012 at 7:37 AM, Roger Pack <rogerdpack2 at gmail.com> wrote:
>
>> > But how to set whether the stream is on by default?  The  subtitle
>> stream has
>> > the default flag, and ffmpeg recognizes it.  I've tried to turn it off
>>
>> So basically you want to tweak the file so that its subtitle stream is
>> set to default "on"?
>> -r
>>
>
> Thanks for reply.  Well in this case the subtitle stream is already set to
> "default",
> meaning that a player should play that stream automatically.  I want to
> turn off
> the default flag, so (assuming the player respects it), it would not play
> unless the
> user chose the subtitle track and turned it on in the player.
>
> Alternatively, in other files I might have several audio tracks and
> several subtitle tracks.
> I want to know how to control the default flag, telling the player which
> track, if any,
> should be played by default.
>
> Actually, I noticed Carl had a related ticket recently
> (https://ffmpeg.org/trac/ffmpeg/ticket/1815; the issue was only asking
> that ffmpeg faithfully copied such flags as "default" and "forced").
> ffmpeg must know how to set/unset these
> flags, I'm just wondering how to control that.  It is probably
> container-dependent,
> and I am currently working with mkv.
> Jim
>

I learned a bit more about the mkv file structure [1,2] and got some
insight into
what might be happening.  Matroska puts these important attributes under a
3rd-level hierarchy as follows: Segments > Tracks > TrackEntry.  Each
TrackEntry
element must have a specific EBML ID.  Some examples follow:

FlagDefault  ID: 88, bool, default=1
FlagForced  ID:55 AA, bool, default=0
Name          ID: 53 6E, utf-8
Language    ID: 22 B5 9C, string

The free-form key-value pairs that ffmpeg generally considers metadata
are stored separately under Segments > Tags.  They have no effect on
playback and players generally ignore them.

I think that TrackEntry elements (at least the ones I'm interested in)
are understood and read correctly by ffmpeg, and are displayed in the
line that starts "Stream # . . .".  The Tags are displayed on separate lines
under a heading "Metadata".

It seems ffmpeg does not write TrackEntry elements as well as it reads them.
The only one that seems half understood is Language.  If you set the
language with a -metadata command, it is displayed correctly as a track
element under "Output".  Then if you have ffmpeg look at the file again, you
find it displayed both there and under Metadata.  The other TrackEntry
attributes
are not recognized as such, and are just treated as arbitrary metadata
(Tags),
so players will ignore them.

I think what is needed is for ffmpeg
to recognize certain key=value pairs in a metadata command
as belonging in the Segments > Tracks > TrackEntry section, rather
than as arbitrary Segments > Tags.  This is certainly related to Ticket
1815 linked
above.  Hopefully this makes sense.

1. http://matroska.org/technical/specs/index.html
2. http://matroska.org/files/matroska.pdf


More information about the ffmpeg-user mailing list