[FFmpeg-devel] [PATCH 2/2] mov: parse track-based udta name tags

Водянников А.В. Aleksoid1978 at mail.ru
Sun Feb 25 04:23:11 EET 2024


From 1833111ec9fe0350e9cf206bb33ca573b6b8c4b5 Mon Sep 17 00:00:00 2001
From: Aleksoid <Aleksoid1978 at mail.ru>
Date: Sun, 25 Feb 2024 11:59:03 +1000
Subject: [PATCH 2/2] mov: parse track-based udta name tags

Signed-off-by: Aleksoid <Aleksoid1978 at mail.ru>
---
 libavformat/mov.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 1a1b104615..c7b6919433 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -301,6 +301,16 @@ static int mov_metadata_hmmt(MOVContext *c, AVIOContext *pb, unsigned len)
     return 0;
 }
 
+
+static void mov_set_metadata(MOVContext *c, const char *key, const char *str)
+{
+    if (c->trak_index >= 0) {
+        AVStream *st = c->fc->streams[c->fc->nb_streams-1];
+        av_dict_set(&st->metadata, key, str, 0);
+    } else
+        av_dict_set(&c->fc->metadata, key, str, 0);
+}
+
 static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 {
     char tmp_key[AV_FOURCC_MAX_STRING_SIZE] = {0};
@@ -403,6 +413,7 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     case MKTAG(0xa9,'w','r','n'): key = "warning";   break;
     case MKTAG(0xa9,'w','r','t'): key = "composer";  break;
     case MKTAG(0xa9,'x','y','z'): key = "location";  break;
+    case MKTAG( 'n','a','m','e'): key = "title";     break;
     }
 retry:
     if (c->itunes_metadata && atom.size > 8) {
@@ -530,10 +541,10 @@ retry:
             str[str_size] = 0;
         }
         c->fc->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED;
-        av_dict_set(&c->fc->metadata, key, str, 0);
+        mov_set_metadata(c, key, str);
         if (*language && strcmp(language, "und")) {
             snprintf(key2, sizeof(key2), "%s-%s", key, language);
-            av_dict_set(&c->fc->metadata, key2, str, 0);
+            mov_set_metadata(c, key2, str);
         }
         if (!strcmp(key, "encoder")) {
             int major, minor, micro;
-- 
2.43.0.windows.1



More information about the ffmpeg-devel mailing list