[FFmpeg-user] change defaults for subtitle streams

Mikołaj Machowski mikmach at wp.pl
Fri Aug 12 11:34:09 EEST 2016


>11.08.2016 14:23, Mikołaj Machowski:
>> I have video with four streams: 0:0 video, 0:1 audio, 0:2 sub1, 0:3 sub2

>> Result of normal settings is that both subtitle streams are default

> Which container or file type is this? I know for certain that multiple
> default streams of the same kind are not allowed in the matroska (.mkv)
> format. For other formats, I am not sure but it does not make sense to
> have more than one default stream per type.

>> and  various players are interpreting this differently eg. ffplay is loading
>> sub1 because this is first, vlc is loading sub2 because this is the last
>> with default flag.

> Case in point. This file should have never existed. ;)

Well, relevant output of ffprobe:

Input #0, matroska,webm, from 'dep5919_2.mkv':
  Metadata:
    ENCODER         : Lavf57.41.100
  Duration: 00:07:44.56, start: 0.000000, bitrate: 42882 kb/s
    Stream #0:0: Video: ffv1 (FFV1 / 0x31564646), yuv420p, 720x576, SAR 16:15 DAR 4:3, 25 fps, 25 tbr, 1k tbn, 1k tbc (default)
    Metadata:
      ENCODER         : Lavc57.50.100 ffv1
      DURATION        : 00:07:44.560000000
    Stream #0:1: Audio: flac, 48000 Hz, stereo, s16 (default)
    Metadata:
      ENCODER         : Lavc57.50.100 flac
      DURATION        : 00:07:44.560000000
    Stream #0:2: Subtitle: dvd_subtitle (default)
    Metadata:
      DURATION        : 00:06:26.520000000
    Stream #0:3: Subtitle: dvd_subtitle (default)
    Metadata:
      DURATION        : 00:06:26.520000000

Don't remember exactly how I created it but it was something like:

$ ffmpeg -i VTS_01_1.VOB -map 0:1 -map 0:2 -map 0:3 -map 0:4 -c:a flac -c:v ffv1 -c:s copy output.mkv

There was no default flag on any sub stream when doing ffprobe on it.

>> How to 'undefault' one of streams and add descriptions?

> You need to change the "disposition", like this:

> $ ffmpeg -i bad_file.mkv -c copy -map 0 -disposition:s:1 -default 
> good_file.mkv

This one didn't work for me, had to recode from the source but with your example could do it properly.
'-disposition' still isn't documented on ffmpeg.org. Grrr.

Interesting that when specifying default for one stream, defaults were removed from all other (added some metadata):

$ ffprobe dep5919_2-4.mkv
Input #0, matroska,webm, from 'dep5919_2-4.mkv':
  Metadata:
    ENCODER         : Lavf57.41.100
  Duration: 00:07:44.56, start: 0.000000, bitrate: 42882 kb/s
    Stream #0:0: Video: ffv1 (FFV1 / 0x31564646), yuv420p, 720x576, SAR 16:15 DAR 4:3, 25 fps, 25 tbr, 1k tbn, 1k tbc
    Metadata:
      ENCODER         : Lavc57.50.100 ffv1
      DURATION        : 00:07:44.560000000
    Stream #0:1(pol): Audio: flac, 48000 Hz, stereo, s16
    Metadata:
      ENCODER         : Lavc57.50.100 flac
      DURATION        : 00:07:44.560000000
    Stream #0:2(eng): Subtitle: dvd_subtitle (default)
    Metadata:
      DURATION        : 00:06:26.520000000
    Stream #0:3(ita): Subtitle: dvd_subtitle
    Metadata:
      DURATION        : 00:06:26.520000000

> More generally it goes like:

> $ ffmpeg -i input -c copy -map 0 -disposition:stream_spec flags output

> More info on stream_spec can be found in the "Stream specifiers"
> section of the ffmpeg manual.

> So, this also works:
> $ ffmpeg -i input -c copy -map 0 -disposition:s:1 +default+forced output

Where can I read about '+' stuff?

> Well, in most cases it works that way. I think for your question this
> answer is valid. But I think I discovered some curiosities while
> testing this feature, when stream_spec is only the type without index,
> so I am not certain, if this is a bug or my above generalisation is
> just too broad. So, for the time being, take it with a grain of salt. :)

Thank you very much for your help.

m.

ps. I don't receive mails from 'my' thread so this message may appear as separate thread.





More information about the ffmpeg-user mailing list