This repository has been archived by the owner. It is now read-only.

Allow/Implement Chapters in WebM files #2002

Closed
jayslovak opened this Issue May 29, 2017 · 8 comments

Comments

@jayslovak

jayslovak commented May 29, 2017

Hello all,

I am transcoding my existing H264/mp4 files to VP9/WebM using ffmpeg and have discovered that I am missing the chapters marks. I have tried to use mkvmerge to re-add them (thinking ffmpeg is broken), and have found it impossible to add them this way:

Chapters are not allowed in WebM compliant files. No chapters will be written to the destination file.

Maybe this was the case some time ago, but nowadays WebM supports a subset of matroska standard chapter specification: WebM Chapter specifications

Please consider implementing the chapter support for WebM.

Thanks!

@optimiz

This comment has been minimized.

Show comment
Hide comment
@optimiz

optimiz May 29, 2017

In the mean time, mkvpropedit conforms to the latest WEBM chapter spec already, use it to add chapters to the WEBM output file...

$ mkvpropedit -c example.chapters example.webm

The file is being analyzed.
The changes are written to the file.
Done.

$ mediainfo example.webm

General
Unique ID : 121210004156520362796212285177745307088 (0x5B3032999CB18B547F26FCE143C6F5D0)
Complete name : example.webm
Format : WebM
Format version : Version 4 / Version 2
File size : 24.5 MiB
Duration : 6 min 4 s
Overall bit rate : 564 kb/s
Movie name : example
Writing application : Lavf56.40.101
Writing library : Lavf56.40.101

Video
ID : 1
Format : VP9
Codec ID : V_VP9
Width : 720 pixels
Height : 480 pixels
Display aspect ratio : 16:9
Frame rate mode : Variable
Language : English
Default : Yes
Forced : No

Audio # 1
ID : 2
Format : Opus
Codec ID : A_OPUS
Duration : 6 min 4 s
Channel(s) : 6 channels
Channel positions : Front: L C R, Rear: L R, LFE
Sampling rate : 48.0 kHz
Bit depth : 32 bits
Compression mode : Lossy
Language : English
Default : Yes
Forced : No

Audio # 2
ID : 3
Format : Opus
Codec ID : A_OPUS
Duration : 6 min 4 s
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 kHz
Bit depth : 32 bits
Compression mode : Lossy
Language : English
Default : No
Forced : No

Menu
00:00:00.000 : en:Chapter 01
00:01:41.834 : en:Chapter 02
00:02:17.201 : en:Chapter 03
00:04:08.834 : en:Chapter 04
00:05:22.500 : en:Chapter 05
00:07:00.168 : en:Chapter 06

optimiz commented May 29, 2017

In the mean time, mkvpropedit conforms to the latest WEBM chapter spec already, use it to add chapters to the WEBM output file...

$ mkvpropedit -c example.chapters example.webm

The file is being analyzed.
The changes are written to the file.
Done.

$ mediainfo example.webm

General
Unique ID : 121210004156520362796212285177745307088 (0x5B3032999CB18B547F26FCE143C6F5D0)
Complete name : example.webm
Format : WebM
Format version : Version 4 / Version 2
File size : 24.5 MiB
Duration : 6 min 4 s
Overall bit rate : 564 kb/s
Movie name : example
Writing application : Lavf56.40.101
Writing library : Lavf56.40.101

Video
ID : 1
Format : VP9
Codec ID : V_VP9
Width : 720 pixels
Height : 480 pixels
Display aspect ratio : 16:9
Frame rate mode : Variable
Language : English
Default : Yes
Forced : No

Audio # 1
ID : 2
Format : Opus
Codec ID : A_OPUS
Duration : 6 min 4 s
Channel(s) : 6 channels
Channel positions : Front: L C R, Rear: L R, LFE
Sampling rate : 48.0 kHz
Bit depth : 32 bits
Compression mode : Lossy
Language : English
Default : Yes
Forced : No

Audio # 2
ID : 3
Format : Opus
Codec ID : A_OPUS
Duration : 6 min 4 s
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 kHz
Bit depth : 32 bits
Compression mode : Lossy
Language : English
Default : No
Forced : No

Menu
00:00:00.000 : en:Chapter 01
00:01:41.834 : en:Chapter 02
00:02:17.201 : en:Chapter 03
00:04:08.834 : en:Chapter 04
00:05:22.500 : en:Chapter 05
00:07:00.168 : en:Chapter 06

@jayslovak

This comment has been minimized.

Show comment
Hide comment
@jayslovak

jayslovak May 30, 2017

Thank you @optimiz for the suggestion, I was able to make this work after I have developed a script to convert from FFMETADATA1 to mkvmerge's simple chapter format.

Let's hope this can get fixed in both mkvmerge and ffmpeg (I have also submitted a corresponding bug report there), so that we don't have to jump through hoops to get chapters incorporated into webm.

Thanks again.

jayslovak commented May 30, 2017

Thank you @optimiz for the suggestion, I was able to make this work after I have developed a script to convert from FFMETADATA1 to mkvmerge's simple chapter format.

Let's hope this can get fixed in both mkvmerge and ffmpeg (I have also submitted a corresponding bug report there), so that we don't have to jump through hoops to get chapters incorporated into webm.

Thanks again.

@optimiz

This comment has been minimized.

Show comment
Hide comment
@optimiz

optimiz Jun 3, 2017

Glad you got it working. You're right, none of ffmpeg's chapter export methods are supported; care to share your translation script? It might be more useful than the "quick and dirty" method I used for the mkvpropedit example above, which was...

  1. remux the original file to a temporary MKV with mkvmerge
  2. extract the chapters from temporary MKV with mkvextract
  3. use mkvpropedit to add extracted chapters after reëncode to WEBM,

For future reference, ffmpeg implemented the WEBM chapter capability based on your ticket (6425) over on their tracker in commit 2ba896f yesterday evening.

optimiz commented Jun 3, 2017

Glad you got it working. You're right, none of ffmpeg's chapter export methods are supported; care to share your translation script? It might be more useful than the "quick and dirty" method I used for the mkvpropedit example above, which was...

  1. remux the original file to a temporary MKV with mkvmerge
  2. extract the chapters from temporary MKV with mkvextract
  3. use mkvpropedit to add extracted chapters after reëncode to WEBM,

For future reference, ffmpeg implemented the WEBM chapter capability based on your ticket (6425) over on their tracker in commit 2ba896f yesterday evening.

@jayslovak

This comment has been minimized.

Show comment
Hide comment
@jayslovak

jayslovak Jun 3, 2017

Sure, here you go: webm_metadatafix.sh

My script loops through my collection of webm files and adds the metadata from metadata.txt. Please note that it assumes the timebase of input metadata is 1/100:

echo "CHAPTER$(printf "%02d" $CHAPTER_ID)=$(printf '%02d:%02d:%02d.%03d\n' $(($CHAPTER_START/100/3600)) $(($CHAPTER_START/100%3600/60)) $(($CHAPTER_START/100%60)) $((10 * ($CHAPTER_START%100))))"

I am also thrilled about ffmpeg implementing the missing functionality so quickly :-)

jayslovak commented Jun 3, 2017

Sure, here you go: webm_metadatafix.sh

My script loops through my collection of webm files and adds the metadata from metadata.txt. Please note that it assumes the timebase of input metadata is 1/100:

echo "CHAPTER$(printf "%02d" $CHAPTER_ID)=$(printf '%02d:%02d:%02d.%03d\n' $(($CHAPTER_START/100/3600)) $(($CHAPTER_START/100%3600/60)) $(($CHAPTER_START/100%60)) $((10 * ($CHAPTER_START%100))))"

I am also thrilled about ffmpeg implementing the missing functionality so quickly :-)

@optimiz

This comment has been minimized.

Show comment
Hide comment
@optimiz

optimiz Jun 4, 2017

Thanks for sharing.

P.S. - The quickest and dirtiest method of all might be to remux the VP9/OPUS files with chapters directly to MKV, then simply rename the file to WEBM.

optimiz commented Jun 4, 2017

Thanks for sharing.

P.S. - The quickest and dirtiest method of all might be to remux the VP9/OPUS files with chapters directly to MKV, then simply rename the file to WEBM.

@jayslovak

This comment has been minimized.

Show comment
Hide comment
@jayslovak

jayslovak Jun 4, 2017

I have tried that of course, and it doesn't work for all use cases. MKV and WebM differ in the DocType field, this make the files unplayable with Chrome :(

jayslovak commented Jun 4, 2017

I have tried that of course, and it doesn't work for all use cases. MKV and WebM differ in the DocType field, this make the files unplayable with Chrome :(

@mbunkus

This comment has been minimized.

Show comment
Hide comment
@mbunkus

mbunkus Jun 11, 2017

Owner

Thanks for the report. I'm currently out sick for quite a while and won't be able to look into it for several weeks.

Owner

mbunkus commented Jun 11, 2017

Thanks for the report. I'm currently out sick for quite a while and won't be able to look into it for several weeks.

@mbunkus

This comment has been minimized.

Show comment
Hide comment
@mbunkus

mbunkus Jul 22, 2017

Owner

For the record: currently mkvpropedit does not create spec-compliant WebM files regarding the chapters. It will try to add several elements that are mandatory according to the Matroska specifications, but are unsupported in WebM (EditionUID, EditionFlagEnabled, ChapterFlagEnabled and others).

Owner

mbunkus commented Jul 22, 2017

For the record: currently mkvpropedit does not create spec-compliant WebM files regarding the chapters. It will try to add several elements that are mandatory according to the Matroska specifications, but are unsupported in WebM (EditionUID, EditionFlagEnabled, ChapterFlagEnabled and others).

mbunkus added a commit that referenced this issue Jul 22, 2017

mbunkus added a commit that referenced this issue Jul 22, 2017

mbunkus added a commit that referenced this issue Jul 22, 2017

propedit: add support for chapters in WebM
Chapters and tags in WebM only allow a subset of elements. The
unsupported ones must be removed before chapters are written to a WebM
file.

Implements mkvpropedit's part of #2002.

mbunkus added a commit that referenced this issue Jul 22, 2017

mbunkus added a commit that referenced this issue Jul 22, 2017

GUI: chapters: add support for chapters in WebM
Chapters and tags in WebM only allow a subset of elements. The
unsupported ones must be removed before chapters are written to a WebM
file.

Implements MKVToolNix GUI's chapter editor's part of #2002.

@mbunkus mbunkus closed this Jul 22, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.