[FFmpeg-devel,2/2] avformat/matroskaenc: also write tags when output is WebM

Submitted by James Almer on June 2, 2017, 2:52 a.m.

Details

Message ID 20170602025200.6780-2-jamrial@gmail.com
State New
Headers show

Commit Message

James Almer June 2, 2017, 2:52 a.m.
WebM supports a subset of elements from the Tags master.
See https://www.webmproject.org/docs/container/#tagging

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavformat/matroskaenc.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

Patch hide | download patch | download mbox

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 24114d6755..80c1a0f38e 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1681,14 +1681,17 @@  static int mkv_write_tags(AVFormatContext *s)
         }
     }
 
-    for (i = 0; i < s->nb_chapters; i++) {
-        AVChapter *ch = s->chapters[i];
+    if (mkv->mode != MODE_WEBM) {
+        for (i = 0; i < s->nb_chapters; i++) {
+            AVChapter *ch = s->chapters[i];
 
-        if (!mkv_check_tag(ch->metadata, MATROSKA_ID_TAGTARGETS_CHAPTERUID))
-            continue;
+            if (!mkv_check_tag(ch->metadata, MATROSKA_ID_TAGTARGETS_CHAPTERUID))
+                continue;
 
-        ret = mkv_write_tag(s, ch->metadata, MATROSKA_ID_TAGTARGETS_CHAPTERUID, ch->id + mkv->chapter_id_offset, &mkv->tags);
-        if (ret < 0) return ret;
+            ret = mkv_write_tag(s, ch->metadata, MATROSKA_ID_TAGTARGETS_CHAPTERUID, ch->id + mkv->chapter_id_offset, &mkv->tags);
+            if (ret < 0)
+                return ret;
+        }
     }
 
     if (mkv->have_attachments) {
@@ -1988,12 +1991,12 @@  static int mkv_write_header(AVFormatContext *s)
         ret = mkv_write_attachments(s);
         if (ret < 0)
             goto fail;
-
-        ret = mkv_write_tags(s);
-        if (ret < 0)
-            goto fail;
     }
 
+    ret = mkv_write_tags(s);
+    if (ret < 0)
+        goto fail;
+
     if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL) && !mkv->is_live)
         mkv_write_seekhead(pb, mkv);