Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#9108 closed defect (invalid)

Unable to process metadata according documentation example

Reported by: Ulf Zibis Owned by:
Priority: normal Component: ffmpeg
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
The "roundtrip" example to edit metadata tags from here
https://ffmpeg.org/ffmpeg-all.html#Metadata-3
in conjunction with the shown metadata example file does not work for adding chapter tags and media title.
Either the documentation is wrong/incomplete or the code is buggy.

How to reproduce:
Use:
http://www.jugkoeln.de/Videos/INPUT_croped.mkv
http://www.jugkoeln.de/Videos/INPUT_test.ffmeta

% ffmpeg -i INPUT_croped.mkv -i INPUT_test.ffmeta -map_metadata 0 -map_metadata 1 -map_metadata:s:v 0:s:v -map_metadata:s:a 0:s:a -c copy OUTPUT_croped.mkv
ffmpeg version N-101141-g8331eb058d Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04)
  configuration: --enable-libvorbis
  libavutil      56. 65.100 / 56. 65.100
  libavcodec     58.123.100 / 58.123.100
  libavformat    58. 67.100 / 58. 67.100
  libavdevice    58. 12.100 / 58. 12.100
  libavfilter     7.107.100 /  7.107.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
Input #0, matroska,webm, from 'INPUT_croped.mkv':
  Metadata:
    SOURCE_TYPE     : dvd
    ENCODER         : Lavf58.67.100
  Duration: 01:31:56.12, start: -0.007000, bitrate: 110 kb/s
  Chapters:
    Chapter #0:0: start 0.000000, end 10.911556
    Chapter #0:1: start 10.911556, end 819.225778
    Chapter #0:2: start 819.225778, end 1839.369956
    Chapter #0:3: start 1839.369956, end 2689.490133
    Chapter #0:4: start 2689.490133, end 3289.574978
    Chapter #0:5: start 3289.574978, end 4584.758089
    Chapter #0:6: start 4584.758089, end 5516.019689
  Stream #0:0: Video: mpeg4 (Simple Profile), yuv420p(progressive), 16x16 [SAR 16:15 DAR 16:15], 25 fps, 25 tbr, 1k tbn, 25 tbc (default)
    Metadata:
      ENCODER         : Lavc58.123.100 mpeg4
      DURATION        : 01:31:56.120000000
  Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
    Metadata:
      DURATION        : 01:31:56.121000000
Input #1, ffmetadata, from 'INPUT_test.ffmeta':
  Metadata:
    title           : Experiment
  Duration: 01:31:56.02, start: 0.000000, bitrate: N/A
  Chapters:
    Chapter #1:0: start 0.000000, end 10.911556
    Chapter #1:1: start 10.911556, end 819.225778
      Metadata:
        title           : 1 - Intro
    Chapter #1:2: start 819.225778, end 1839.369956
      Metadata:
        title           : 2 - Restaurant
    Chapter #1:3: start 1839.369956, end 2689.490133
      Metadata:
        title           : 3 - At home
    Chapter #1:4: start 2689.490133, end 3289.574978
    Chapter #1:5: start 3289.574978, end 4584.758089
    Chapter #1:6: start 4584.758089, end 5516.019689
Codec 0x21000 is not in the full list.
  Stream #1:0: Data: unknown_codec
    Metadata:
      title           : Experiment
File 'OUTPUT_croped.mkv' already exists. Overwrite? [y/N] y
Output #0, matroska, to 'OUTPUT_croped.mkv':
  Metadata:
    SOURCE_TYPE     : dvd
    title           : Experiment
    encoder         : Lavf58.67.100
  Chapters:
    Chapter #0:0: start 0.007000, end 10.918556
    Chapter #0:1: start 10.918556, end 819.232778
    Chapter #0:2: start 819.232778, end 1839.376956
    Chapter #0:3: start 1839.376956, end 2689.497133
    Chapter #0:4: start 2689.497133, end 3289.581978
    Chapter #0:5: start 3289.581978, end 4584.765089
    Chapter #0:6: start 4584.765089, end 5516.026689
  Stream #0:0: Video: mpeg4 (Simple Profile) (FMP4 / 0x34504D46), yuv420p(progressive), 16x16 [SAR 16:15 DAR 16:15], q=2-31, 25 fps, 25 tbr, 1k tbn, 1k tbc (default)
    Metadata:
      ENCODER         : Lavc58.123.100 mpeg4
      DURATION        : 01:31:56.120000000
  Stream #0:1(eng): Audio: opus ([255][255][255][255] / 0xFFFFFFFF), 48000 Hz, stereo, fltp (default)
    Metadata:
      DURATION        : 01:31:56.121000000
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=137903 fps=15555 q=-1.0 Lsize=   74660kB time=01:31:56.10 bitrate= 110.9kbits/s speed= 622x    
video:1498kB audio:70033kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 4.375239%

Result: The chapter titles are not added to the output and the media title seems not to be added to the right place, as media players – e.g. VLC – don't show the title at the expected place, see attachment.
As side effect, the global metadata changes to an unusual form and order:

    Metadata:
      SOURCE_TYPE     : dvd
      title           : Experiment
      encoder         : Lavf58.67.100

instead:

    Metadata:
      SOURCE_TYPE     : dvd
      ENCODER         : Lavf58.67.100
      title           : Experiment

Also adding the media title as stream title doesn't help:

% ffmpeg -i INPUT_croped.mkv -i INPUT_test.ffmeta -map_metadata 0 -map_metadata 1 -map_metadata:s:v 0:s:v -map_metadata:s:a 0:s:a -map_metadata:s 1:s -c copy OUTPUT_croped.mkv
ffmpeg version N-101141-g8331eb058d Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04)
  configuration: --enable-libvorbis
  libavutil      56. 65.100 / 56. 65.100
  libavcodec     58.123.100 / 58.123.100
  libavformat    58. 67.100 / 58. 67.100
  libavdevice    58. 12.100 / 58. 12.100
  libavfilter     7.107.100 /  7.107.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
Input #0, matroska,webm, from 'INPUT_croped.mkv':
  Metadata:
    SOURCE_TYPE     : dvd
    ENCODER         : Lavf58.67.100
  Duration: 01:31:56.12, start: -0.007000, bitrate: 110 kb/s
  Chapters:
    Chapter #0:0: start 0.000000, end 10.911556
    Chapter #0:1: start 10.911556, end 819.225778
    Chapter #0:2: start 819.225778, end 1839.369956
    Chapter #0:3: start 1839.369956, end 2689.490133
    Chapter #0:4: start 2689.490133, end 3289.574978
    Chapter #0:5: start 3289.574978, end 4584.758089
    Chapter #0:6: start 4584.758089, end 5516.019689
  Stream #0:0: Video: mpeg4 (Simple Profile), yuv420p(progressive), 16x16 [SAR 16:15 DAR 16:15], 25 fps, 25 tbr, 1k tbn, 25 tbc (default)
    Metadata:
      ENCODER         : Lavc58.123.100 mpeg4
      DURATION        : 01:31:56.120000000
  Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
    Metadata:
      DURATION        : 01:31:56.121000000
Input #1, ffmetadata, from 'INPUT_test.ffmeta':
  Metadata:
    title           : Experiment
  Duration: 01:31:56.02, start: 0.000000, bitrate: N/A
  Chapters:
    Chapter #1:0: start 0.000000, end 10.911556
    Chapter #1:1: start 10.911556, end 819.225778
      Metadata:
        title           : 1 - Intro
    Chapter #1:2: start 819.225778, end 1839.369956
      Metadata:
        title           : 2 - Restaurant
    Chapter #1:3: start 1839.369956, end 2689.490133
      Metadata:
        title           : 3 - At home
    Chapter #1:4: start 2689.490133, end 3289.574978
    Chapter #1:5: start 3289.574978, end 4584.758089
    Chapter #1:6: start 4584.758089, end 5516.019689
Codec 0x21000 is not in the full list.
  Stream #1:0: Data: unknown_codec
    Metadata:
      title           : Experiment
File 'OUTPUT_croped.mkv' already exists. Overwrite? [y/N] y
Output #0, matroska, to 'OUTPUT_croped.mkv':
  Metadata:
    SOURCE_TYPE     : dvd
    title           : Experiment
    encoder         : Lavf58.67.100
  Chapters:
    Chapter #0:0: start 0.007000, end 10.918556
    Chapter #0:1: start 10.918556, end 819.232778
    Chapter #0:2: start 819.232778, end 1839.376956
    Chapter #0:3: start 1839.376956, end 2689.497133
    Chapter #0:4: start 2689.497133, end 3289.581978
    Chapter #0:5: start 3289.581978, end 4584.765089
    Chapter #0:6: start 4584.765089, end 5516.026689
  Stream #0:0: Video: mpeg4 (Simple Profile) (FMP4 / 0x34504D46), yuv420p(progressive), 16x16 [SAR 16:15 DAR 16:15], q=2-31, 25 fps, 25 tbr, 1k tbn, 1k tbc (default)
    Metadata:
      ENCODER         : Lavc58.123.100 mpeg4
      DURATION        : 01:31:56.120000000
      title           : Experiment
  Stream #0:1(eng): Audio: opus ([255][255][255][255] / 0xFFFFFFFF), 48000 Hz, stereo, fltp (default)
    Metadata:
      DURATION        : 01:31:56.121000000
      title           : Experiment
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=137903 fps=23403 q=-1.0 Lsize=   74660kB time=01:31:56.10 bitrate= 110.9kbits/s speed= 936x    
video:1498kB audio:70033kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 4.375275%

Result:
The media title is still not shown with SMPlayer and VLC media player.

As an alternative, the chapter titles can be added using option -map_chapters:

% ffmpeg -i INPUT_croped.mkv -i INPUT_test.ffmeta -map_metadata 0 -map_metadata 1 -map_metadata:s:v 0:s:v -map_metadata:s:a 0:s:a -map_metadata:s 1:s -map_chapters 1 -c copy OUTPUT_croped.mkv
ffmpeg version N-101141-g8331eb058d Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04)
  configuration: --enable-libvorbis
  libavutil      56. 65.100 / 56. 65.100
  libavcodec     58.123.100 / 58.123.100
  libavformat    58. 67.100 / 58. 67.100
  libavdevice    58. 12.100 / 58. 12.100
  libavfilter     7.107.100 /  7.107.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
Input #0, matroska,webm, from 'INPUT_croped.mkv':
  Metadata:
    SOURCE_TYPE     : dvd
    ENCODER         : Lavf58.67.100
  Duration: 01:31:56.12, start: -0.007000, bitrate: 110 kb/s
  Chapters:
    Chapter #0:0: start 0.000000, end 10.911556
    Chapter #0:1: start 10.911556, end 819.225778
    Chapter #0:2: start 819.225778, end 1839.369956
    Chapter #0:3: start 1839.369956, end 2689.490133
    Chapter #0:4: start 2689.490133, end 3289.574978
    Chapter #0:5: start 3289.574978, end 4584.758089
    Chapter #0:6: start 4584.758089, end 5516.019689
  Stream #0:0: Video: mpeg4 (Simple Profile), yuv420p(progressive), 16x16 [SAR 16:15 DAR 16:15], 25 fps, 25 tbr, 1k tbn, 25 tbc (default)
    Metadata:
      ENCODER         : Lavc58.123.100 mpeg4
      DURATION        : 01:31:56.120000000
  Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
    Metadata:
      DURATION        : 01:31:56.121000000
Input #1, ffmetadata, from 'INPUT_test.ffmeta':
  Metadata:
    title           : Experiment
  Duration: 01:31:56.02, start: 0.000000, bitrate: N/A
  Chapters:
    Chapter #1:0: start 0.000000, end 10.911556
    Chapter #1:1: start 10.911556, end 819.225778
      Metadata:
        title           : 1 - Intro
    Chapter #1:2: start 819.225778, end 1839.369956
      Metadata:
        title           : 2 - Restaurant
    Chapter #1:3: start 1839.369956, end 2689.490133
      Metadata:
        title           : 3 - At home
    Chapter #1:4: start 2689.490133, end 3289.574978
    Chapter #1:5: start 3289.574978, end 4584.758089
    Chapter #1:6: start 4584.758089, end 5516.019689
Codec 0x21000 is not in the full list.
  Stream #1:0: Data: unknown_codec
    Metadata:
      title           : Experiment
File 'OUTPUT_croped.mkv' already exists. Overwrite? [y/N] y
Output #0, matroska, to 'OUTPUT_croped.mkv':
  Metadata:
    SOURCE_TYPE     : dvd
    title           : Experiment
    encoder         : Lavf58.67.100
  Chapters:
    Chapter #0:0: start 0.000000, end 10.911556
    Chapter #0:1: start 10.911556, end 819.225778
      Metadata:
        title           : 1 - Intro
    Chapter #0:2: start 819.225778, end 1839.369956
      Metadata:
        title           : 2 - Restaurant
    Chapter #0:3: start 1839.369956, end 2689.490133
      Metadata:
        title           : 3 - At home
    Chapter #0:4: start 2689.490133, end 3289.574978
    Chapter #0:5: start 3289.574978, end 4584.758089
    Chapter #0:6: start 4584.758089, end 5516.019689
  Stream #0:0: Video: mpeg4 (Simple Profile) (FMP4 / 0x34504D46), yuv420p(progressive), 16x16 [SAR 16:15 DAR 16:15], q=2-31, 25 fps, 25 tbr, 1k tbn, 1k tbc (default)
    Metadata:
      ENCODER         : Lavc58.123.100 mpeg4
      DURATION        : 01:31:56.120000000
      title           : Experiment
  Stream #0:1(eng): Audio: opus ([255][255][255][255] / 0xFFFFFFFF), 48000 Hz, stereo, fltp (default)
    Metadata:
      DURATION        : 01:31:56.121000000
      title           : Experiment
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=137903 fps=23424 q=-1.0 Lsize=   74660kB time=01:31:56.10 bitrate= 110.9kbits/s speed= 937x    
video:1498kB audio:70033kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 4.375388%

Conclusion:

  1. It would be good, if the round trip example from

https://ffmpeg.org/ffmpeg-all.html#Metadata-3
would work out of the box, even for chapter and media titles.

  1. At least. description of option -map_metadata at

https://ffmpeg.org/ffmpeg-all.html#Advanced-options
should refer to option -map_chapters for editing chapter tags.

  1. And both option descriptions should be cross-linked with

https://ffmpeg.org/ffmpeg-all.html#Metadata-1

Attachments (1)

VLC title & chapters.png (58.7 KB ) - added by Ulf Zibis 3 years ago.
With VLC title is greyed out

Download all attachments as: .zip

Change History (5)

by Ulf Zibis, 3 years ago

Attachment: VLC title & chapters.png added

With VLC title is greyed out

comment:1 by Elon Musk, 3 years ago

Resolution: wontfix
Status: newclosed

comment:2 by mkver, 3 years ago

Resolution: wontfixinvalid

You did not map the chapters of the ffmetadata file: -map_chapters 1 will actually use them and add chapter titles to the output.

comment:3 by Ulf Zibis, 3 years ago

In the 3rd command you can see, that I did so. But in my opinion, https://ffmpeg.org/ffmpeg-all.html#Metadata-1 is missing to point on that and even the description of option map_metadata.
Additionally it is not possible to set the media title at the location where common media players expect to find it for displaying.

comment:4 by mkver, 3 years ago

So you want that -map_chapters 1 should be added to the command for reinserting metadata? Probably makes sense.

I can assure you that FFmpeg/libavformat's Matroska muxer writes the title where players expect it (there is a problem with edition titles though, but that is irrelevant to your question). It's been a while since I last used VLC, but isn't this "Titel" thing only used for navigating the entries of a playlist?

Note: See TracTickets for help on using tickets.