[FFmpeg-trac] #7549(avformat:new): Matroska Edition Titles used as Segment Title

FFmpeg trac at avcodec.org
Thu Nov 15 17:07:01 EET 2018


#7549: Matroska Edition Titles used as Segment Title
---------------------------------------+----------------------------------
               Reporter:  dericed      |                  Owner:
                   Type:  defect       |                 Status:  new
               Priority:  normal       |              Component:  avformat
                Version:  unspecified  |               Keywords:  matroska
             Blocked By:               |               Blocking:
Reproduced by developer:  0            |  Analyzed by developer:  0
---------------------------------------+----------------------------------
 Summary of the bug:

 Hi, I'm using Matroska files with ordered editions and these have Edition
 titles but there is no Segment title. I notice that FFmpeg is
 interpretting the default Edition title as the Segment title anyway
 though. Also when remuxing the Edition title is then mapped to the Segment
 title which IMHO is not intended.

 How to reproduce:

 # create a sample Matroska file
 {{{
 ffmpeg -y -f lavfi -i "smptebars=s=720x480:r=25:d=5" -f lavfi -i
 "aevalsrc=0.1*sin(1000*2*PI*t):d=5:s=48000:c=stereo" -f lavfi -i
 "color=color=black:s=720x480:r=25:d=5" -f lavfi -i
 "aevalsrc=0:d=5:s=48000:c=stereo" -f lavfi -i
 "color=s=2x2:r=1:d=6,format=gray,geq=lum=4-N,datascope=s=24x12,crop=6:12:10:0,scale=iw*30:ih*30:flags=neighbor,pad=720:480:(720-iw)/2:(480-ih)/2,fps=25"
 -f lavfi -i "sine=r=48000:frequency=1:beep_factor=400:duration=5" -f lavfi
 -i
 "nullsrc=s=720x480:r=25:d=5,geq=random(1)/hypot(X-cos(N*0.07)*W/2-W/2\,Y-sin(N*0.09)*H/2-H/2)^2*1000000*sin(N*0.02):128:128,geq=r='X/W*r(X,Y)':g='(1-X/W)*g(X,Y)':b='(H-Y)/H*b(X,Y)'"
 -f lavfi -i "anoisesrc=colour=pink:d=5:r=48000,tremolo=f=0.1:d=0.9" -f
 lavfi -i "color=color=black:s=720x480:r=25:d=5" -f lavfi -i
 "aevalsrc=0:d=5:s=48000:c=stereo" -filter_complex
 "[0:v][1:a][2:v][3:a][4:v][5:a][6:v][7:a][8:v][9:a]concat=n=5:v=1:a=1[v];[v]scale=240x120"
 -c:v ffv1 -c:a flac chapters_test.mkv
 }}}

 Use the following files to express chapters and tags.
 # tags.xml
 {{{
 <?xml version="1.0"?>
 <!-- <!DOCTYPE Tags SYSTEM "matroskatags.dtd"> -->
 <Tags>
   <Tag>
     <Targets>
       <EditionUID>12338659363134957115</EditionUID>
       <TargetTypeValue>50</TargetTypeValue>
     </Targets>
     <Simple>
       <Name>TITLE</Name>
       <String>Full Transfer</String>
       <TagLanguage>eng</TagLanguage>
       <DefaultLanguage>1</DefaultLanguage>
     </Simple>
   </Tag>
   <Tag>
     <Targets>
       <EditionUID>3475548369</EditionUID>
       <TargetTypeValue>50</TargetTypeValue>
     </Targets>
     <Simple>
       <Name>TITLE</Name>
       <String>Presentation</String>
       <TagLanguage>eng</TagLanguage>
       <DefaultLanguage>1</DefaultLanguage>
     </Simple>
   </Tag>
 </Tags>
 }}}

 chapters.xml
 {{{
 <?xml version="1.0"?>
 <!-- <!DOCTYPE Chapters SYSTEM "matroskachapters.dtd"> -->
 <Chapters>
   <EditionEntry>
     <EditionFlagOrdered>1</EditionFlagOrdered>
     <EditionFlagHidden>0</EditionFlagHidden>
     <EditionFlagDefault>1</EditionFlagDefault>
     <EditionUID>3475548369</EditionUID>
     <ChapterAtom>
       <ChapterTimeStart>00:00:15.000000000</ChapterTimeStart>
       <ChapterTimeEnd>00:00:20.000000000</ChapterTimeEnd>
       <ChapterFlagHidden>0</ChapterFlagHidden>
       <ChapterFlagEnabled>1</ChapterFlagEnabled>
       <ChapterUID>15183902702307841284</ChapterUID>
       <ChapterDisplay>
         <ChapterString>Fuzzy Ball</ChapterString>
         <ChapterLanguage>eng</ChapterLanguage>
       </ChapterDisplay>
     </ChapterAtom>
   </EditionEntry>
   <EditionEntry>
     <EditionFlagOrdered>1</EditionFlagOrdered>
     <EditionFlagHidden>0</EditionFlagHidden>
     <EditionFlagDefault>0</EditionFlagDefault>
     <EditionUID>12338659363134957115</EditionUID>
     <ChapterAtom>
       <ChapterTimeStart>00:00:00.000000000</ChapterTimeStart>
       <ChapterTimeEnd>00:00:05.000000000</ChapterTimeEnd>
       <ChapterFlagHidden>0</ChapterFlagHidden>
       <ChapterFlagEnabled>1</ChapterFlagEnabled>
       <ChapterUID>14224305391220421330</ChapterUID>
       <ChapterDisplay>
         <ChapterString>Color Bars</ChapterString>
         <ChapterLanguage>eng</ChapterLanguage>
       </ChapterDisplay>
     </ChapterAtom>
     <ChapterAtom>
       <ChapterTimeStart>00:00:05.000000000</ChapterTimeStart>
       <ChapterTimeEnd>00:00:10.000000000</ChapterTimeEnd>
       <ChapterFlagHidden>0</ChapterFlagHidden>
       <ChapterFlagEnabled>1</ChapterFlagEnabled>
       <ChapterUID>14224305391220421331</ChapterUID>
       <ChapterDisplay>
         <ChapterString>Black Frames</ChapterString>
         <ChapterLanguage>eng</ChapterLanguage>
       </ChapterDisplay>
     </ChapterAtom>
     <ChapterAtom>
       <ChapterTimeStart>00:00:10.000000000</ChapterTimeStart>
       <ChapterTimeEnd>00:00:15.000000000</ChapterTimeEnd>
       <ChapterFlagHidden>0</ChapterFlagHidden>
       <ChapterFlagEnabled>1</ChapterFlagEnabled>
       <ChapterUID>14224305391220421332</ChapterUID>
       <ChapterDisplay>
         <ChapterString>Countdown</ChapterString>
         <ChapterLanguage>eng</ChapterLanguage>
       </ChapterDisplay>
     </ChapterAtom>
     <ChapterAtom>
       <ChapterTimeStart>00:00:15.000000000</ChapterTimeStart>
       <ChapterTimeEnd>00:00:20.000000000</ChapterTimeEnd>
       <ChapterFlagHidden>0</ChapterFlagHidden>
       <ChapterFlagEnabled>1</ChapterFlagEnabled>
       <ChapterUID>14224305391220421333</ChapterUID>
       <ChapterDisplay>
         <ChapterString>Fuzzy Ball</ChapterString>
         <ChapterLanguage>eng</ChapterLanguage>
       </ChapterDisplay>
     </ChapterAtom>
     <ChapterAtom>
       <ChapterTimeStart>00:00:20.000000000</ChapterTimeStart>
       <ChapterTimeEnd>00:00:25.000000000</ChapterTimeEnd>
       <ChapterFlagHidden>0</ChapterFlagHidden>
       <ChapterFlagEnabled>1</ChapterFlagEnabled>
       <ChapterUID>14224305391220421334</ChapterUID>
       <ChapterDisplay>
         <ChapterString>Black Frames</ChapterString>
         <ChapterLanguage>eng</ChapterLanguage>
       </ChapterDisplay>
     </ChapterAtom>
   </EditionEntry>
 </Chapters>
 }}}

 Mux chapters and tags into MKV file.
 {{{
 mkvpropedit chapters_test.mkv -c chapters.xml -t global:tags.xml
 }}}

 The output of mkvpropedit is attached as a sample. An ffmpeg -i shows
 {{{
 ffmpeg -i chapters_test.mkv
 ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
   built with Apple LLVM version 9.0.0 (clang-900.0.38)
   configuration: --prefix=/usr/local/Cellar/ffmpeg/4.1 --enable-shared
 --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-
 avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay
 --enable-gpl --enable-libmp3lame --enable-libopus --enable-libsnappy
 --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264
 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfreetype
 --enable-opencl --enable-videotoolbox
   libavutil      56. 22.100 / 56. 22.100
   libavcodec     58. 35.100 / 58. 35.100
   libavformat    58. 20.100 / 58. 20.100
   libavdevice    58.  5.100 / 58.  5.100
   libavfilter     7. 40.101 /  7. 40.101
   libavresample   4.  0.  0 /  4.  0.  0
   libswscale      5.  3.100 /  5.  3.100
   libswresample   3.  3.100 /  3.  3.100
   libpostproc    55.  3.100 / 55.  3.100
 Input #0, matroska,webm, from 'chapters_test.mkv':
   Metadata:
     encoder         : Lavf58.20.100
     TITLE           : Presentation
     TITLE-eng       : Presentation
   Duration: 00:00:25.00, start: 0.000000, bitrate: 533 kb/s
     Chapter #0:0: start 15.000000, end 20.000000
     Metadata:
       title           : Fuzzy Ball
     Chapter #0:1: start 20.000000, end 25.000000
     Metadata:
       title           : Black Frames
     Stream #0:0: Audio: flac, 48000 Hz, stereo, s32 (24 bit) (default)
     Metadata:
       ENCODER         : Lavc58.35.100 flac
       DURATION        : 00:00:25.000000000
     Stream #0:1: Video: ffv1 (FFV1 / 0x31564646), yuv420p, 240x120, SAR
 3:4 DAR 3:2, 25 fps, 25 tbr, 1k tbn, 1k tbc (default)
     Metadata:
       ENCODER         : Lavc58.35.100 ffv1
       DURATION        : 00:00:25.000000000
 At least one output file must be specified
 }}}

 Presentation is the title of the default edition but not for the segment
 which was intentionally left blank.
 When remuxing such as `ffmpeg -i chapters_test.mkv -c copy -map 0
 output.mkv`, then the edition title is mapped to the segment title and
 then the title of the edition is lost.

 {{{
 ffmpeg -i chapters_test.mkv -c copy -map 0 output.mkv
 ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
   built with Apple LLVM version 9.0.0 (clang-900.0.38)
   configuration: --prefix=/usr/local/Cellar/ffmpeg/4.1 --enable-shared
 --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-
 avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay
 --enable-gpl --enable-libmp3lame --enable-libopus --enable-libsnappy
 --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264
 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfreetype
 --enable-opencl --enable-videotoolbox
   libavutil      56. 22.100 / 56. 22.100
   libavcodec     58. 35.100 / 58. 35.100
   libavformat    58. 20.100 / 58. 20.100
   libavdevice    58.  5.100 / 58.  5.100
   libavfilter     7. 40.101 /  7. 40.101
   libavresample   4.  0.  0 /  4.  0.  0
   libswscale      5.  3.100 /  5.  3.100
   libswresample   3.  3.100 /  3.  3.100
   libpostproc    55.  3.100 / 55.  3.100
 Input #0, matroska,webm, from 'chapters_test.mkv':
   Metadata:
     encoder         : Lavf58.20.100
     TITLE           : Presentation
     TITLE-eng       : Presentation
   Duration: 00:00:25.00, start: 0.000000, bitrate: 533 kb/s
     Chapter #0:0: start 15.000000, end 20.000000
     Metadata:
       title           : Fuzzy Ball
     Chapter #0:1: start 20.000000, end 25.000000
     Metadata:
       title           : Black Frames
     Stream #0:0: Audio: flac, 48000 Hz, stereo, s32 (24 bit) (default)
     Metadata:
       ENCODER         : Lavc58.35.100 flac
       DURATION        : 00:00:25.000000000
     Stream #0:1: Video: ffv1 (FFV1 / 0x31564646), yuv420p, 240x120, SAR
 3:4 DAR 3:2, 25 fps, 25 tbr, 1k tbn, 1k tbc (default)
     Metadata:
       ENCODER         : Lavc58.35.100 ffv1
       DURATION        : 00:00:25.000000000
 Output #0, matroska, to 'output.mkv':
   Metadata:
     TITLE-eng       : Presentation
     TITLE           : Presentation
     encoder         : Lavf58.20.100
     Chapter #0:0: start 15.000000, end 20.000000
     Metadata:
       title           : Fuzzy Ball
     Chapter #0:1: start 20.000000, end 25.000000
     Metadata:
       title           : Black Frames
     Stream #0:0: Audio: flac ([172][241][0][0] / 0xF1AC), 48000 Hz,
 stereo, s32 (24 bit) (default)
     Metadata:
       ENCODER         : Lavc58.35.100 flac
       DURATION        : 00:00:25.000000000
     Stream #0:1: Video: ffv1 (FFV1 / 0x31564646), yuv420p, 240x120 [SAR
 3:4 DAR 3:2], q=2-31, 25 fps, 25 tbr, 1k tbn, 1k tbc (default)
     Metadata:
       ENCODER         : Lavc58.35.100 ffv1
       DURATION        : 00:00:25.000000000
 Stream mapping:
   Stream #0:0 -> #0:0 (copy)
   Stream #0:1 -> #0:1 (copy)
 Press [q] to stop, [?] for help
 frame=  625 fps=0.0 q=-1.0 Lsize=    1628kB time=00:00:24.96 bitrate=
 534.1kbits/s speed=1.55e+03x
 video:493kB audio:1126kB subtitle:0kB other streams:0kB global headers:0kB
 muxing overhead: 0.542953%
 }}}

 Here's the resulting tags of the output.mkv
 {{{
 mkvextract tags output.mkv
 <?xml version="1.0"?>
 <!-- <!DOCTYPE Tags SYSTEM "matroskatags.dtd"> -->
 <Tags>
   <Tag>
     <Targets />
     <Simple>
       <Name>TITLE</Name>
       <TagLanguage>eng</TagLanguage>
       <String>Presentation</String>
     </Simple>
     <Simple>
       <Name>ENCODER</Name>
       <String>Lavf58.20.100</String>
     </Simple>
   </Tag>
   <Tag>
     <Targets>
       <TrackUID>1</TrackUID>
     </Targets>
     <Simple>
       <Name>ENCODER</Name>
       <String>Lavc58.35.100 flac</String>
     </Simple>
   </Tag>
   <Tag>
     <Targets>
       <TrackUID>2</TrackUID>
     </Targets>
     <Simple>
       <Name>ENCODER</Name>
       <String>Lavc58.35.100 ffv1</String>
     </Simple>
   </Tag>
   <Tag>
     <Targets>
       <TrackUID>1</TrackUID>
     </Targets>
     <Simple>
       <Name>DURATION</Name>
       <String>00:00:25.000000000</String>
     </Simple>
   </Tag>
   <Tag>
     <Targets>
       <TrackUID>2</TrackUID>
     </Targets>
     <Simple>
       <Name>DURATION</Name>
       <String>00:00:25.000000000</String>
     </Simple>
   </Tag>
 </Tags>
 }}}
 Note, now the editions are untitled, and the default edition title is now
 without a target, so implied to be the Segment title.

 Also in output.mkv the non-default edition is completely lost:

 {{{
 mkvextract chapters output.mkv
 <?xml version="1.0"?>
 <!-- <!DOCTYPE Chapters SYSTEM "matroskachapters.dtd"> -->
 <Chapters>
   <EditionEntry>
     <EditionFlagDefault>1</EditionFlagDefault>
     <EditionFlagHidden>0</EditionFlagHidden>
     <ChapterAtom>
       <ChapterUID>2529763887</ChapterUID>
       <ChapterTimeStart>00:00:15.000000000</ChapterTimeStart>
       <ChapterTimeEnd>00:00:20.000000000</ChapterTimeEnd>
       <ChapterFlagHidden>0</ChapterFlagHidden>
       <ChapterFlagEnabled>1</ChapterFlagEnabled>
       <ChapterDisplay>
         <ChapterString>Fuzzy Ball</ChapterString>
         <ChapterLanguage>und</ChapterLanguage>
       </ChapterDisplay>
     </ChapterAtom>
     <ChapterAtom>
       <ChapterUID>1</ChapterUID>
       <ChapterTimeStart>00:00:20.000000000</ChapterTimeStart>
       <ChapterTimeEnd>00:00:25.000000000</ChapterTimeEnd>
       <ChapterFlagHidden>0</ChapterFlagHidden>
       <ChapterFlagEnabled>1</ChapterFlagEnabled>
       <ChapterDisplay>
         <ChapterString>Black Frames</ChapterString>
         <ChapterLanguage>und</ChapterLanguage>
       </ChapterDisplay>
     </ChapterAtom>
   </EditionEntry>
 </Chapters>
 }}}

 Patches should be submitted to the ffmpeg-devel mailing list and not this
 bug tracker.

--
Ticket URL: <https://trac.ffmpeg.org/ticket/7549>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list