Opened 11 years ago
Closed 11 years ago
#2790 closed defect (fixed)
FFmpeg moves content of first chapter from a mkv file into global
Reported by: | Fabian | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | avformat |
Version: | git-master | Keywords: | mkv |
Cc: | jamal | Blocked By: | |
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
Summary of the bug:
When I create a mkv file with chapters using the ffmetadata file and then parse it by ffmpeg again, it will remove the first chapter and some metadata of it become global.
How to reproduce:
% ./ffmpeg -i src_meta.txt -i src_video.webm -c copy tgt_video.mkv ffmpeg version N-54769-g5ceffb1 Copyright (c) 2000-2013 the FFmpeg developers built on Jul 16 2013 22:14:51 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5) configuration: --disable-yasm libavutil 52. 39.100 / 52. 39.100 libavcodec 55. 18.102 / 55. 18.102 libavformat 55. 12.102 / 55. 12.102 libavdevice 55. 3.100 / 55. 3.100 libavfilter 3. 81.101 / 3. 81.101 libswscale 2. 3.100 / 2. 3.100 libswresample 0. 17.102 / 0. 17.102 Input #0, ffmetadata, from 'src_meta.txt': Duration: 00:00:09.42, start: 0.000000, bitrate: 0 kb/s Chapter #0.0: start 0.000000, end 0.990000 Metadata: TITLE : Chapter 1 TYPE : c1 Chapter #0.1: start 1.000000, end 9.420000 Metadata: TITLE : Chapter 2 TYPE : c2 Input #1, matroska,webm, from 'src_video.webm': Duration: 00:00:09.42, start: 0.000000, bitrate: 1827 kb/s Stream #1:0: Video: vp8, yuv420p, 1280x720, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 1k tbn, 1k tbc (default) Stream #1:1: Audio: vorbis, 48000 Hz, stereo, fltp (default) Output #0, matroska, to 'tgt_video.mkv': Metadata: encoder : Lavf55.12.102 Chapter #0.0: start 0.000000, end 0.990000 Metadata: TITLE : Chapter 1 TYPE : c1 Chapter #0.1: start 1.000000, end 9.420000 Metadata: TITLE : Chapter 2 TYPE : c2 Stream #0:0: Video: vp8 (VP80 / 0x30385056), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 25 fps, 1k tbn, 1k tbc (default) Stream #0:1: Audio: vorbis (oV[0][0] / 0x566F), 48000 Hz, stereo (default) Stream mapping: Stream #1:0 -> #0:0 (copy) Stream #1:1 -> #0:1 (copy) Press [q] to stop, [?] for help frame= 234 fps=0.0 q=-1.0 Lsize= 2101kB time=00:00:09.39 bitrate=1831.7kbits/s video:1945kB audio:146kB subtitle:0 global headers:0kB muxing overhead 0.467363% % ./ffmpeg -i tgt_video.mkv -f ffmetadata tgt_meta.txt ffmpeg version N-54769-g5ceffb1 Copyright (c) 2000-2013 the FFmpeg developers built on Jul 16 2013 22:14:51 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5) configuration: --disable-yasm libavutil 52. 39.100 / 52. 39.100 libavcodec 55. 18.102 / 55. 18.102 libavformat 55. 12.102 / 55. 12.102 libavdevice 55. 3.100 / 55. 3.100 libavfilter 3. 81.101 / 3. 81.101 libswscale 2. 3.100 / 2. 3.100 libswresample 0. 17.102 / 0. 17.102 Input #0, matroska,webm, from 'tgt_video.mkv': Metadata: ENCODER : Lavf55.12.102 TYPE : c1 Duration: 00:00:09.42, start: 0.000000, bitrate: 1827 kb/s Chapter #0.0: start 1.000000, end 9.420000 Metadata: title : Chapter 2 TYPE : c2 Stream #0:0: Video: vp8, yuv420p, 1280x720, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 1k tbn, 1k tbc (default) Stream #0:1: Audio: vorbis, 48000 Hz, stereo, fltp (default) Output #0, ffmetadata, to 'tgt_meta.txt': Metadata: ENCODER : Lavf55.12.102 TYPE : c1 Chapter #0.0: start 1.000000, end 9.420000 Metadata: title : Chapter 2 TYPE : c2 Stream mapping: Press [q] to stop, [?] for help size= 0kB time=-577014:-32:-22.-77 bitrate=N/A video:0kB audio:0kB subtitle:0 global headers:0kB muxing overhead inf% Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
As you can see, the first chapter is missing and starts directly with the second. Additionally it shows the TYPE metadata of the first chapter in the global metadata.
I used mkvtoolnix to look into the file and there the first chapter exists, so it looks like the decoding failed. Although I tried it with another proprietary mkv file and there it works fine. Unfortunately I can't upload that file.
I used http://http://commons.wikimedia.org/wiki/File:Chinese_Signal.webm to encode and this is the metadata file:
;FFMETADATA1 [CHAPTER] TIMEBASE=1/100 START=0 END=99 TITLE=Chapter 1 TYPE=c1 [CHAPTER] TIMEBASE=1/100 START=100 END=942 TITLE=Chapter 2 TYPE=c2
And mkvtoolnix is producing the following:
+ EBML head |+ EBML version: 1 |+ EBML read version: 1 |+ EBML maximum ID length: 4 |+ EBML maximum size length: 8 |+ Doc type: matroska |+ Doc type version: 2 |+ Doc type read version: 2 + Segment, size 2151327 |+ Seek head (subentries will be skipped) |+ EbmlVoid (size: 133) |+ Segment information | + Timecode scale: 1000000 | + Muxing application: Lavf55.12.102 | + Writing application: Lavf55.12.102 | + Segment UID:0xf2 0x8c 0x0b 0x70 0x15 0x18 0x4d 0x25 0x54 0xc7 0xfd 0xd7 0x92 0x17 0xe7 0x31 | + Duration: 9.417s (00:00:09.417) |+ Segment tracks | + A track | + Track number: 1 | + Track UID: 1 | + Lacing flag: 0 | + Language: und | + Default flag: 1 | + Codec ID: V_VP8 | + Track type: video | + Default duration: 40.000ms (25.000 fps for a video track) | + Video track | + Pixel width: 1280 | + Pixel height: 720 | + Display width: 1280 | + Display height: 720 | + A track | + Track number: 2 | + Track UID: 2 | + Lacing flag: 0 | + Language: und | + Default flag: 1 | + Codec ID: A_VORBIS | + Track type: audio | + Audio track | + Channels: 2 | + Sampling frequency: 48000 | + Bit depth: 32 | + CodecPrivate, length 4256 |+ Chapters | + EditionEntry | + EditionFlagDefault: 1 | + EditionFlagHidden: 0 | + ChapterAtom | + ChapterUID: 0 | + ChapterTimeStart: 00:00:00.000000000 | + ChapterTimeEnd: 00:00:00.990000000 | + ChapterFlagHidden: 0 | + ChapterFlagEnabled: 1 | + ChapterDisplay | + ChapterString: Chapter 1 | + ChapterLanguage: und | + ChapterAtom | + ChapterUID: 1 | + ChapterTimeStart: 00:00:01.000000000 | + ChapterTimeEnd: 00:00:09.420000000 | + ChapterFlagHidden: 0 | + ChapterFlagEnabled: 1 | + ChapterDisplay | + ChapterString: Chapter 2 | + ChapterLanguage: und |+ Tags | + Tag | + Targets | + Simple | + Name: ENCODER | + String: Lavf55.12.102 | + Tag | + Targets | + ChapterUID: 0 | + Simple | + Name: TYPE | + String: c1 | + Tag | + Targets | + ChapterUID: 1 | + Simple | + Name: TYPE | + String: c2 |+ Cluster
Thanks in advance.
Fabian
Attachments (3)
Change History (9)
by , 11 years ago
Attachment: | src_meta.txt added |
---|
by , 11 years ago
Attachment: | tgt_video.mkv added |
---|
The result of applying the source metadata to the video on the commons
follow-up: 3 comment:1 by , 11 years ago
"ChapterUID: 0"
That seems to the problem. The Matroska demuxer is ignoring the chapter with uid 0, and reading the second one (With uid 1) as if it were the first.
The ffmetadata demuxer assigns the id 0 to the first chapter it reads from src_meta.txt, and the Matroska muxer used it.
mkvalidator doesn't complain about the resulting file tgt_video.mkv, so 0 is a valid value for ChapterUID.
comment:2 by , 11 years ago
Component: | undetermined → avformat |
---|---|
Keywords: | mkv added; chapter matroska removed |
Priority: | minor → normal |
follow-up: 4 comment:3 by , 11 years ago
Cc: | added |
---|
Replying to jamal:
0 is a valid value for ChapterUID.
I don't think this is correct, see http://matroska.org/technical/specs/index.html
comment:4 by , 11 years ago
Replying to cehoyos:
Replying to jamal:
0 is a valid value for ChapterUID.
I don't think this is correct, see http://matroska.org/technical/specs/index.html
Odd, I'd expect their own validator to catch that.
comment:5 by , 11 years ago
So avformat “simply” needs to start the ChapterUID with 1 instead of 0? That may explain why my proprietary file is working when the ChapterUIDs look like random generated.
Now I have a bunch of mkvs with the wrong ChapterUID, so maybe ffmpeg can support a ChapterUID of 0 and I can simply reformat them to a valid format.
My source metadata