[FFmpeg-devel] [PATCH v2 1/1] mov: read track title
Dong Nguyen
nguyenduydong at gmail.com
Wed Oct 13 03:01:03 EEST 2021
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 at gmail.com>
---
libavformat/mov.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
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);
--
2.27.0.rc0
More information about the ffmpeg-devel
mailing list