Opened 5 years ago

Closed 4 years ago

#8173 closed defect (fixed)

MKV - All streams marked as default when trying to remove all dispositions

Reported by: nheelyolis Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: mkv, disposition
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug

When trying to demux or encode an MKV file to another MKV file, all streams get marked as "default" when I'm trying to delete all dispositions in that file with -disposition[:stream_specifier] 0. You can't see it during the process itself, but if you do a ffprobe on the resulted file, you'll see that all its streams are marked as default.

Even if it's expected behavior (which doesn't look so to me), why doesn't it say that the output streams will be default during encoding/demuxing?

How to reproduce

  1. Take any MKV file which has at least 1 stream marked as default.
  2. Demux this file deleting all its dispositions.
    % ffmpeg -i in.mkv -map 0 -disposition:v:0 0 -c copy out.mkv
    ffmpeg version N-94959-g96f1d34d0c Copyright (c) 2000-2019 the FFmpeg developers
      built with gcc 9.1.0 (GCC)
      configuration: 
      libavutil      56. 35.100 / 56. 35.100
      libavcodec     58. 57.100 / 58. 57.100
      libavformat    58. 32.104 / 58. 32.104
      libavdevice    58.  9.100 / 58.  9.100
      libavfilter     7. 58.102 /  7. 58.102
      libswscale      5.  6.100 /  5.  6.100
      libswresample   3.  6.100 /  3.  6.100
    Input #0, matroska,webm, from 'in.mkv':
      Metadata:
        ENCODER         : Lavf58.29.100
      Duration: 00:14:48.06, start: -0.007000, bitrate: 3437 kb/s
        Stream #0:0(eng): Video: vp8, yuv420p(progressive), 1920x818, SAR 1:1 DAR 960:409, 24 fps, 24 tbr, 1k tbn, 1k tbc (default)
        Metadata:
          DURATION        : 00:14:48.055000000
        Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, fltp
        Metadata:
          DURATION        : 00:14:48.061000000
        Stream #0:2(eng): Subtitle: webvtt
        Metadata:
          DURATION        : 00:10:29.807000000
    Output #0, matroska, to 'out.mkv':
      Metadata:
        encoder         : Lavf58.32.104
        Stream #0:0(eng): Video: vp8 (VP80 / 0x30385056), yuv420p(progressive), 1920x818 [SAR 1:1 DAR 960:409], q=2-31, 24 fps, 24 tbr, 1k tbn, 1k tbc
        Metadata:
          DURATION        : 00:14:48.055000000
        Stream #0:1(eng): Audio: opus ([255][255][255][255] / 0xFFFFFFFF), 48000 Hz, stereo, fltp
        Metadata:
          DURATION        : 00:14:48.061000000
        Stream #0:2(eng): Subtitle: webvtt
        Metadata:
          DURATION        : 00:10:29.807000000
    Stream mapping:
      Stream #0:0 -> #0:0 (copy)
      Stream #0:1 -> #0:1 (copy)
      Stream #0:2 -> #0:2 (copy)
    Press [q] to stop, [?] for help
    frame=22308 fps=13499 q=-1.0 Lsize=  372673kB time=00:14:48.04 bitrate=3437.8kbits/s speed= 537x    
    video:358428kB audio:13768kB subtitle:1kB other streams:0kB global headers:0kB muxing overhead: 0.127906%
    
  1. Probe the resulted file and notice that all the streams are "default".
    % ffprobe out.mkv
    ffprobe version N-94959-g96f1d34d0c Copyright (c) 2007-2019 the FFmpeg developers
      built with gcc 9.1.0 (GCC)
      configuration: 
      libavutil      56. 35.100 / 56. 35.100
      libavcodec     58. 57.100 / 58. 57.100
      libavformat    58. 32.104 / 58. 32.104
      libavdevice    58.  9.100 / 58.  9.100
      libavfilter     7. 58.102 /  7. 58.102
      libswscale      5.  6.100 /  5.  6.100
      libswresample   3.  6.100 /  3.  6.100
    Input #0, matroska,webm, from 'out.mkv':
      Metadata:
        ENCODER         : Lavf58.32.104
      Duration: 00:14:48.06, start: -0.007000, bitrate: 3437 kb/s
        Stream #0:0(eng): Video: vp8, yuv420p(progressive), 1920x818, SAR 1:1 DAR 960:409, 24 fps, 24 tbr, 1k tbn, 1k tbc (default)
        Metadata:
          DURATION        : 00:14:48.062000000
        Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
        Metadata:
          DURATION        : 00:14:48.061000000
        Stream #0:2(eng): Subtitle: webvtt (default)
        Metadata:
          DURATION        : 00:10:29.814000000
    

Change History (5)

comment:1 by Balling, 4 years ago

Status: newopen

What is default if all is default, BTW?

in reply to:  1 comment:2 by nheelyolis, 4 years ago

Replying to Balling:

What is default if all is default, BTW?

Even when you have only one stream of each type, having disposition set to default does make a difference. It tells (in my understanding) that the stream absolutely should be used. For example, setting default disposition to subtitles forces the media player (I personally use mpv) to enable the subtitles. While normally you would have to enable them manually.

And when you have more than one stream of some type, setting all of them to default doesn't seem to make any sense. You obviously can't play two video streams at the same time, or two audio streams, etc. So it becomes up to media player to choose a stream, which leads to the same file being played differently by different media players. Because as far as I'm aware, this behavior is not defined anywhere. You are very welcome to correct me if I'm wrong.

comment:3 by Balling, 4 years ago

You obviously can't play two video streams at the same time

You can and have to in Dolby Vision dual layer... Just saying. Of course it should be reconstructed actually to one stream...

two audio streams

Technically 7.1 EAC3 on Blu-rays is dual stream...

this behavior is not defined anywhere

Well, the logical choice would be to choose stream with smallest ID

in reply to:  3 comment:4 by nheelyolis, 4 years ago

Replying to Balling:

You can and have to in Dolby Vision dual layer... Just saying. Of course it should be reconstructed actually to one stream...
Technically 7.1 EAC3 on Blu-rays is dual stream...

It's good to know, but it hardly has to do anything with dispositions. My point was that default disposition isn't meant to be set on multiple streams of the same type. And even if it's meant to, the user probably would want to do that explicitly.

Well, the logical choice would be to choose stream with smallest ID

It's logical, but it's still undefined. mpv for example does just that, while vlc tries to select subtitles with the same language as video (at least I think so, from my experiments).

comment:5 by mkver, 4 years ago

Component: ffmpegavformat
Resolution: fixed
Status: openclosed

Fixed in e3c54b549abf2798422245582c0ed775c894ddeb. Your aim can be achieved by removing all dispositions (at least the "default" bit) and using the passthrough mode.

Note: See TracTickets for help on using tickets.