diff mbox series

[FFmpeg-devel,v2,1/1] mov: read track title

Message ID 20211013000103.10725-1-nguyenduydong@gmail.com
State New
Headers show
Series [FFmpeg-devel,v2,1/1] mov: read track title
Related show

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Dong Nguyen Oct. 13, 2021, 12:01 a.m. UTC
this change fixes issue [9438](https://trac.ffmpeg.org/ticket/9438)

after commit da9cc22d5bd5f59756c2037b02966376da2cf323
ffmpeg is able to write track title metadata to mov/mp4 format file
but it is not able to read back the metadata

if `udta` box is inside track box then update AvStream's metadata
instead of AVFormatContext.

Signed-off-by: Dong Nguyen <nguyenduydong@gmail.com>
---
 libavformat/mov.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/mov.c b/libavformat/mov.c
index a811bc7677..26d33db5cd 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -380,6 +380,12 @@  static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     case MKTAG(0xa9,'l','y','r'): key = "lyrics";    break;
     case MKTAG(0xa9,'m','a','k'): key = "make";      break;
     case MKTAG(0xa9,'m','o','d'): key = "model";     break;
+    case MKTAG('n','a','m','e') :
+        if (c->trak_index >= 0) { // meta inside track
+            key = "title";
+            raw = 1;
+        }
+        break;
     case MKTAG(0xa9,'n','a','m'): key = "title";     break;
     case MKTAG(0xa9,'o','p','e'): key = "original_artist"; break;
     case MKTAG(0xa9,'p','r','d'): key = "producer";  break;
@@ -520,8 +526,13 @@  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) {
+            c->fc->streams[c->trak_index]->event_flags |= AVSTREAM_EVENT_FLAG_METADATA_UPDATED;
+            av_dict_set(&c->fc->streams[c->trak_index]->metadata, key, str, 0);
+        } else {
+            c->fc->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED;
+            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);