[FFmpeg-devel] [PATCH v1] libavformat/mov: ffmpeg can't read mp4 track title metadata

xutopiaf at gmail.com xutopiaf at gmail.com
Wed Oct 20 05:38:20 EEST 2021


From: xutopia <xutopiaf at gmail.com>

Signed-off-by: xutopia <xutopiaf at gmail.com>
---
 libavformat/mov.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 57c67e3aac..9673234734 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -521,7 +521,17 @@ retry:
             str[str_size] = 0;
         }
         c->fc->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED;
-        av_dict_set(&c->fc->metadata, key, str, 0);
+
+        if (c->trak_index >= 0) {
+            if (c->trak_index < c->fc->nb_streams) {
+                av_dict_set(&c->fc->streams[c->trak_index]->metadata, key, str, 0);
+            } else {
+                av_log(c->fc, AV_LOG_ERROR, "current trck idx=%d > streams=%d\n", c->trak_index, c->fc->nb_streams);
+            }
+        } else {
+            av_dict_set(&c->fc->metadata, key, str, 0);
+        }
+        
         if (*language && strcmp(language, "und")) {
             snprintf(key2, sizeof(key2), "%s-%s", key, language);
             av_dict_set(&c->fc->metadata, key2, str, 0);
-- 
2.25.1



More information about the ffmpeg-devel mailing list