Opened 13 months ago

Last modified 12 months ago

#7549 new defect

Matroska Edition Titles used as Segment Title

Reported by: dericed Owned by:
Priority: normal Component: avformat
Version: unspecified Keywords: mkv
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

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.

Attachments (2)

chapters_test.mkv (1.6 MB) - added by dericed 13 months ago.
chapters_test.mkv
output.mkv (1.6 MB) - added by dericed 13 months ago.
output.mkv (after a remux via ffmpeg)

Change History (4)

Changed 13 months ago by dericed

chapters_test.mkv

Changed 13 months ago by dericed

output.mkv (after a remux via ffmpeg)

comment:1 Changed 13 months ago by cehoyos

  • Keywords mkv added; matroska removed

Is this issue reproducible with current FFmpeg git head?

comment:2 Changed 12 months ago by dericed

yes, i rebuilt just now using git-head and the result was the same.

I do notice that ffmpeg -i on both the input and output are interpretted similarly although the files contain very different segment info and chapter info.

ffmpeg -i chapters_test.mkv -i output.mkv 
ffmpeg version N-53923-gb41f378fc4 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/HEAD-b41f378 --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-opencl --enable-videotoolbox
  libavutil      56. 24.101 / 56. 24.101
  libavcodec     58. 42.100 / 58. 42.100
  libavformat    58. 24.100 / 58. 24.100
  libavdevice    58.  6.101 / 58.  6.101
  libavfilter     7. 46.101 /  7. 46.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
Input #0, matroska,webm, from 'chapters_test.mkv':
  Metadata:
    encoder         : Lavf58.24.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.42.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.42.100 ffv1
      DURATION        : 00:00:25.000000000
Input #1, matroska,webm, from 'output.mkv':
  Metadata:
    title           : Presentation
    TITLE-eng       : Presentation
    ENCODER         : Lavf58.24.100
  Duration: 00:00:25.00, start: 0.000000, bitrate: 533 kb/s
    Chapter #1:0: start 15.000000, end 20.000000
    Metadata:
      title           : Fuzzy Ball
    Chapter #1:1: start 20.000000, end 25.000000
    Metadata:
      title           : Black Frames
    Stream #1:0: Audio: flac, 48000 Hz, stereo, s32 (24 bit) (default)
    Metadata:
      ENCODER         : Lavc58.42.100 flac
      DURATION        : 00:00:25.000000000
    Stream #1: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.42.100 ffv1
      DURATION        : 00:00:25.000000000
At least one output file must be specified
Note: See TracTickets for help on using tickets.