id,summary,reporter,owner,description,type,status,priority,component,version,resolution,keywords,cc,blockedby,blocking,reproduced,analyzed
1815,FFmpeg does not copy the default and forced track flags for matroka files,billie,,"The first output is from a sample file I have created with mmg from mkvtoolnix with every possible combination of the forced and default flags. mmg allows one default track for all video, audio and subtitle tracks but multiple forced tracks.

The second/third/fourth output is the result from ""ffmpeg -i test_orig.mkv -c: copy -map 0 -f matroska test_ffmpeg_*.mkv"". Currently ffmpeg seems to drop the forced flag and every stream which has no flag gets the default flag.

I took a look at libavformat/matroskaenc.c applied the changes from the attached patch. The patch only works if I add the forced flag before the default flag with put_ebml_uint. If I add it afterwards I get the third output. Here existing flags were kept but all streams without flags still get the default flags.

Adding the forced flag before adding the default flag gives the desired fourth output. All flags are copied correctly.

I do not have any experience in c programming, so I am not sure if this is the correct fix so I would be glad if somebody could take a look at this.

Furthermore is it possible to add a way of setting this flags with ffmpeg, currently this seems not doable.

1: ffmpeg -i test_orig.mkv 2>&1 | grep Stream
Stream #0:0: Video: h264 (High), yuv420p, 720x576 [SAR 64:45 DAR 16:9], 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
Stream #0:1(ger): Audio: ac3, 48000 Hz, 5.1(side), s16, 448 kb/s (default) (forced)
Stream #0:2(ger): Audio: ac3, 48000 Hz, 5.1(side), s16, 448 kb/s (forced)
Stream #0:3(ger): Audio: ac3, 48000 Hz, 5.1(side), s16, 448 kb/s
Stream #0:4(ger): Subtitle: dvd_subtitle (default)
Stream #0:5(ger): Subtitle: dvd_subtitle (forced)
Stream #0:6(ger): Subtitle: dvd_subtitle

2: ffmpeg -i test_ffmpeg_orig.mkv 2>&1 | grep Stream
Stream #0:0: Video: h264 (High), yuv420p, 720x576 [SAR 64:45 DAR 16:9], 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
Stream #0:1(ger): Audio: ac3, 48000 Hz, 5.1(side), s16, 448 kb/s (default)
Stream #0:2(ger): Audio: ac3, 48000 Hz, 5.1(side), s16, 448 kb/s
Stream #0:3(ger): Audio: ac3, 48000 Hz, 5.1(side), s16, 448 kb/s (default)
Stream #0:4(ger): Subtitle: dvd_subtitle (default)
Stream #0:5(ger): Subtitle: dvd_subtitle
Stream #0:6(ger): Subtitle: dvd_subtitle (default)

3: ffmpeg -i test_ffmpeg_forced_after.mkv 2>&1 | grep Stream
Stream #0:0: Video: h264 (High), yuv420p, 720x576 [SAR 64:45 DAR 16:9], 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
Stream #0:1(ger): Audio: ac3, 48000 Hz, 5.1(side), s16, 448 kb/s (default) (forced)
Stream #0:2(ger): Audio: ac3, 48000 Hz, 5.1(side), s16, 448 kb/s (forced)
Stream #0:3(ger): Audio: ac3, 48000 Hz, 5.1(side), s16, 448 kb/s (default)
Stream #0:4(ger): Subtitle: dvd_subtitle (default)
Stream #0:5(ger): Subtitle: dvd_subtitle (forced)
Stream #0:6(ger): Subtitle: dvd_subtitle (default)

4: ffmpeg -i test_ffmpeg_forced_before.mkv 2>&1 | grep Stream
Stream #0:0: Video: h264 (High), yuv420p, 720x576 [SAR 64:45 DAR 16:9], 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
Stream #0:1(ger): Audio: ac3, 48000 Hz, 5.1(side), s16, 448 kb/s (default) (forced)
Stream #0:2(ger): Audio: ac3, 48000 Hz, 5.1(side), s16, 448 kb/s (forced)
Stream #0:3(ger): Audio: ac3, 48000 Hz, 5.1(side), s16, 448 kb/s
Stream #0:4(ger): Subtitle: dvd_subtitle (default)
Stream #0:5(ger): Subtitle: dvd_subtitle (forced)
Stream #0:6(ger): Subtitle: dvd_subtitle
",defect,closed,normal,avformat,git-master,fixed,mkv,,,,1,0
