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.
This commit is contained in:
Moritz Bunkus 2017-07-22 14:51:55 +02:00
parent 191384fe63
commit a6fbfa1e70
4 changed files with 21 additions and 11 deletions

View File

@ -19,9 +19,9 @@
* mkvmerge: AAC: implemented support for AAC with 960 samples per
frame. Implements #2031.
* mkvmerge: WAV reader: added support for Wave64 files. Implements #2042.
* mkvmerge, mkvpropedit: added support for chapters in WebM files that is
spec-compliant by removing all tag elements not supported by the WebM
spec. Implements #2002.
* mkvmerge, mkvpropedit, MKVToolNix GUI (chapter editor): added support for
chapters in WebM files that is spec-compliant by removing all tag elements
not supported by the WebM spec. Implements #2002.
* mkvpropedit: added support for tags in WebM files that is spec-compliant by
removing all tag elements not supported by the WebM spec.

View File

@ -577,7 +577,7 @@ Tab::load() {
d->savedState = currentState();
auto result = kax_analyzer_c::probe(to_utf8(d->fileName)) ? loadFromMatroskaFile()
: d->fileName.toLower().endsWith(Q(".mpls")) ? loadFromMplsFile()
: loadFromChapterFile();
: loadFromChapterFile();
if (result.first)
chaptersLoaded(result.first, result.second);
@ -705,7 +705,11 @@ Tab::saveToMatroskaImpl(bool requireNewFileName) {
if (doRequireNewFileName) {
auto defaultFilePath = !d->fileName.isEmpty() ? QFileInfo{d->fileName}.path() : Util::Settings::get().lastOpenDirPath();
newFileName = Util::getOpenFileName(this, QY("Save chapters to Matroska file"), defaultFilePath, QY("Matroska files") + Q(" (*.mkv *.mka *.mks *.mk3d);;") + QY("All files") + Q(" (*)"));
newFileName = Util::getOpenFileName(this, QY("Save chapters to Matroska or WebM file"), defaultFilePath,
QY("Supported file types") + Q(" (*.mkv *.mka *.mks *.mk3d *.webm);;") +
QY("Matroska files") + Q(" (*.mkv *.mka *.mks *.mk3d);;") +
QY("WebM files") + Q(" (*.webm);;") +
QY("All files") + Q(" (*)"));
if (newFileName.isEmpty())
return false;
@ -727,9 +731,14 @@ Tab::saveToMatroskaImpl(bool requireNewFileName) {
auto chapters = d->chapterModel->allChapters();
auto result = kax_analyzer_c::uer_success;
if (chapters && (0 != chapters->ListSize()))
result = d->analyzer->update_element(chapters, true);
else
if (chapters && (0 != chapters->ListSize())) {
fix_mandatory_chapter_elements(chapters.get());
if (d->analyzer->is_webm())
remove_chapter_elements_unsupported_by_webm(*chapters);
result = d->analyzer->update_element(chapters, !d->analyzer->is_webm(), false);
} else
result = d->analyzer->remove_elements(EBML_ID(KaxChapters));
d->analyzer->close_file();

View File

@ -178,8 +178,9 @@ Tool::openFilesFromCommandLine(QStringList const &fileNames) {
void
Tool::selectFileToOpen() {
auto fileNames = Util::getOpenFileNames(this, QY("Open files in chapter editor"), Util::Settings::get().lastOpenDirPath(),
QY("Supported file types") + Q(" (*.cue *.mpls *.mkv *.mka *.mks *.mk3d *.txt *.xml);;") +
QY("Supported file types") + Q(" (*.cue *.mpls *.mkv *.mka *.mks *.mk3d *.txt *.webm *.xml);;") +
QY("Matroska files") + Q(" (*.mkv *.mka *.mks *.mk3d);;") +
QY("WebM files") + Q(" (*.webm);;") +
QY("Blu-ray playlist files") + Q(" (*.mpls);;") +
QY("XML chapter files") + Q(" (*.xml);;") +
QY("Simple OGM-style chapter files") + Q(" (*.txt);;") +

View File

@ -413,7 +413,7 @@
<normaloff>:/icons/16x16/document-open.png</normaloff>:/icons/16x16/document-open.png</iconset>
</property>
<property name="text">
<string>&amp;Open Matroska or chapter file</string>
<string>&amp;Open Matroska, WebM or chapter file</string>
</property>
<property name="shortcut">
<string>Ctrl+O</string>
@ -450,7 +450,7 @@
</action>
<action name="actionChapterEditorSaveToMatroska">
<property name="text">
<string>Save to &amp;Matroska file</string>
<string>Save to &amp;Matroska or WebM file</string>
</property>
</action>
<action name="actionChapterEditorReload">