Ticket #1815 (closed defect: fixed)

Opened 7 months ago

Last modified 4 months ago

FFmpeg does not copy the default and forced track flags for matroka files

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

Description

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

Attachments

0001-copy-default-and-forced-track-flags.patch Download (974 bytes) - added by billie 7 months ago.
Possible fix to copy the track flags
test_orig.mkv Download (375.1 KB) - added by billie 7 months ago.
Sample input file

Change History

Changed 7 months ago by billie

Possible fix to copy the track flags

comment:1 Changed 7 months ago by cehoyos

  • Keywords mkv added

Please provide complete, uncut console output together with a failing command line and please provide an input sample.

comment:2 Changed 7 months ago by billie

The failing command line including the output. Note the flags are displayed correctly in the input and output block when copying but issuing "ffmpeg -i" for the output file shows that the flags are not copied.

./ffmpeg/ffmpeg -i test_orig.mkv -c: copy -map 0 -f matroska test_ffmpeg_orig.mkv
ffmpeg version N-45565-gcf1f1a2 Copyright (c) 2000-2012 the FFmpeg developers
  built on Oct 15 2012 20:56:40 with gcc 4.5.4 (Gentoo 4.5.4 p1.0, pie-0.4.7)
  configuration: --cc=i686-pc-linux-gnu-gcc --cxx=i686-pc-linux-gnu-g++ --ar=i686-pc-linux-gnu-ar --optflags='-march=native -O2 -pipe -fomit-frame-pointer' --extra-cflags='-march=native -O2 -pipe -fomit-frame-pointer' --extra-cxxflags='-march=native -O2 -pipe -fomit-frame-pointer' --enable-gpl --enable-version3 --enable-postproc --enable-avfilter --disable-stripping --disable-debug --disable-doc --disable-vdpau --disable-ffplay --enable-gnutls --enable-libmp3lame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-libaacplus --enable-nonfree --enable-libfaac --enable-nonfree --enable-libcdio --enable-libdc1394 --enable-openal --disable-indev=v4l --disable-indev=jack --enable-x11grab --enable-libv4l2 --disable-outdev=sdl --enable-frei0r --enable-libfreetype --enable-libass --enable-pthreads --enable-libopencore-amrwb --enable-libopencore-amrnb --enable-libgsm --enable-libmodplug --enable-libschroedinger --enable-libspeex --enable-libvp  libavutil      51. 76.100 / 51. 76.100
  libavcodec     54. 66.100 / 54. 66.100
  libavformat    54. 32.101 / 54. 32.101
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 19.102 /  3. 19.102
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 16.100 /  0. 16.100
  libpostproc    52.  1.100 / 52.  1.100
Input #0, matroska,webm, from 'test_orig.mkv':
  Metadata:
    creation_time   : 2012-10-15 18:28:54
  Duration: 00:00:30.01, start: 0.000000, bitrate: 102 kb/s
    Stream #0:0: Video: h264 (High), yuv420p, 320x240, SAR 1:1 DAR 4:3, 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
    Stream #0:1: Audio: ac3, 48000 Hz, stereo, s16, 32 kb/s (default) (forced)
    Stream #0:2: Audio: ac3, 48000 Hz, stereo, s16, 32 kb/s (forced)
    Stream #0:3: Audio: ac3, 48000 Hz, stereo, s16, 32 kb/s
    Stream #0:4: Subtitle: dvd_subtitle (default)
    Stream #0:5: Subtitle: dvd_subtitle (forced)
    Stream #0:6: Subtitle: dvd_subtitle
Output #0, matroska, to 'test_ffmpeg_orig.mkv':
  Metadata:
    encoder         : Lavf54.32.101
    Stream #0:0: Video: h264, yuv420p, 320x240 [SAR 1:1 DAR 4:3], q=2-31, 25 fps, 1k tbn, 1k tbc (default)
    Stream #0:1: Audio: ac3, 48000 Hz, stereo, 32 kb/s (default) (forced)
    Stream #0:2: Audio: ac3, 48000 Hz, stereo, 32 kb/s (forced)
    Stream #0:3: Audio: ac3, 48000 Hz, stereo, 32 kb/s
    Stream #0:4: Subtitle: dvd_subtitle (default)
    Stream #0:5: Subtitle: dvd_subtitle (forced)
    Stream #0:6: Subtitle: dvd_subtitle
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
  Stream #0:2 -> #0:2 (copy)
  Stream #0:3 -> #0:3 (copy)
  Stream #0:4 -> #0:4 (copy)
  Stream #0:5 -> #0:5 (copy)
  Stream #0:6 -> #0:6 (copy)
Press [q] to stop, [?] for help
frame=  750 fps=0.0 q=-1.0 Lsize=     393kB time=00:00:30.01 bitrate= 107.3kbits/s    
video:13kB audio:352kB subtitle:3 global headers:0kB muxing overhead 6.875788%
./ffmpeg/ffmpeg -i test_ffmpeg_orig.mkv
ffmpeg version N-45565-gcf1f1a2 Copyright (c) 2000-2012 the FFmpeg developers
  built on Oct 15 2012 20:56:40 with gcc 4.5.4 (Gentoo 4.5.4 p1.0, pie-0.4.7)
  configuration: --cc=i686-pc-linux-gnu-gcc --cxx=i686-pc-linux-gnu-g++ --ar=i686-pc-linux-gnu-ar --optflags='-march=native -O2 -pipe -fomit-frame-pointer' --extra-cflags='-march=native -O2 -pipe -fomit-frame-pointer' --extra-cxxflags='-march=native -O2 -pipe -fomit-frame-pointer' --enable-gpl --enable-version3 --enable-postproc --enable-avfilter --disable-stripping --disable-debug --disable-doc --disable-vdpau --disable-ffplay --enable-gnutls --enable-libmp3lame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-libaacplus --enable-nonfree --enable-libfaac --enable-nonfree --enable-libcdio --enable-libdc1394 --enable-openal --disable-indev=v4l --disable-indev=jack --enable-x11grab --enable-libv4l2 --disable-outdev=sdl --enable-frei0r --enable-libfreetype --enable-libass --enable-pthreads --enable-libopencore-amrwb --enable-libopencore-amrnb --enable-libgsm --enable-libmodplug --enable-libschroedinger --enable-libspeex --enable-libvp  libavutil      51. 76.100 / 51. 76.100
  libavcodec     54. 66.100 / 54. 66.100
  libavformat    54. 32.101 / 54. 32.101
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 19.102 /  3. 19.102
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 16.100 /  0. 16.100
  libpostproc    52.  1.100 / 52.  1.100
Input #0, matroska,webm, from 'test_ffmpeg_orig.mkv':
  Metadata:
    ENCODER         : Lavf54.32.101
  Duration: 00:00:30.09, start: 0.000000, bitrate: 107 kb/s
    Stream #0:0: Video: h264 (High), yuv420p, 320x240, SAR 1:1 DAR 4:3, 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
    Stream #0:1: Audio: ac3, 48000 Hz, stereo, s16, 32 kb/s (default)
    Stream #0:2: Audio: ac3, 48000 Hz, stereo, s16, 32 kb/s
    Stream #0:3: Audio: ac3, 48000 Hz, stereo, s16, 32 kb/s (default)
    Stream #0:4: Subtitle: dvd_subtitle (default)
    Stream #0:5: Subtitle: dvd_subtitle
    Stream #0:6: Subtitle: dvd_subtitle (default)
At least one output file must be specified
Last edited 7 months ago by billie (previous) (diff)

Changed 7 months ago by billie

Sample input file

comment:3 Changed 7 months ago by cehoyos

  • Status changed from new to open
  • Reproduced by developer set

comment:4 Changed 4 months ago by cehoyos

  • Type changed from enhancement to defect

Copying the forced track flag is fixed, I sent a patch for the bug with "default" streams:
 http://thread.gmane.org/gmane.comp.video.ffmpeg.devel/158229

comment:5 Changed 4 months ago by cehoyos

  • Status changed from open to closed
  • Resolution set to fixed

Should be fixed, thank you for the report!

Note: See TracTickets for help on using tickets.