Message ID | 20180521141853.6124-1-nik@nikjohnson.net |
---|---|
State | Superseded |
Headers | show |
2018-05-21 16:18 GMT+02:00, Nik Johnson <nik@nikjohnson.net>: > Some muxers produce mp4s with a udta (user data) atom nested within a > trak atom. The nested udta atoms typically contain stream information > such as the title. ffmpeg should treat nested udta atoms as applicable > to the stream instead of globally. Please also provide a sample. Carl Eugen
For lack of a better option here's a dropbox link. The ftp://upload.ffmpeg.org server doesn't appear to respond. This is a tiny clip unmodified from NVidia Shadowplay. (5.4MB) https://www.dropbox.com/s/6izrx87gfsgjodq/mov-trak-name-shadowplay.mp4?dl=0 ------ Original Message ------ From: "Carl Eugen Hoyos" <ceffmpeg@gmail.com> To: "FFmpeg development discussions and patches" <ffmpeg-devel@ffmpeg.org> Sent: 5/21/2018 4:36:09 PM Subject: Re: [FFmpeg-devel] [PATCH 1/2] libavformat/mov: treat udta atoms within trak atoms as stream metadata >2018-05-21 16:18 GMT+02:00, Nik Johnson <nik@nikjohnson.net>: >>Some muxers produce mp4s with a udta (user data) atom nested within a >>trak atom. The nested udta atoms typically contain stream information >>such as the title. ffmpeg should treat nested udta atoms as applicable >>to the stream instead of globally. > >Please also provide a sample. > >Carl Eugen >_______________________________________________ >ffmpeg-devel mailing list >ffmpeg-devel@ffmpeg.org >http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
diff --git a/libavformat/mov.c b/libavformat/mov.c index 1975011741..5332d48eb1 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -306,6 +306,8 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom) int (*parse)(MOVContext*, AVIOContext*, unsigned, const char*) = NULL; int raw = 0; int num = 0; + AVStream *st; + AVDictionary **metadata; switch (atom.type) { case MKTAG( '@','P','R','M'): key = "premiere_version"; raw = 1; break; @@ -514,12 +516,23 @@ retry: } str[str_size] = 0; } - c->fc->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED; - av_dict_set(&c->fc->metadata, key, str, 0); + + // A udta atom may occur inside a trak atom when specifying trak + // specific user data. For example, some muxers define a trak name. + if (c->fc->nb_streams > 0 && c->trak_index != -1) { + st = c->fc->streams[c->fc->nb_streams-1]; + st->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED; + metadata = &st->metadata; + } else { + c->fc->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED; + metadata = &c->fc->metadata; + } + av_dict_set(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); + av_dict_set(metadata, key2, str, 0); } + if (!strcmp(key, "encoder")) { int major, minor, micro; if (sscanf(str, "HandBrake %d.%d.%d", &major, &minor, µ) == 3) {
Some muxers produce mp4s with a udta (user data) atom nested within a trak atom. The nested udta atoms typically contain stream information such as the title. ffmpeg should treat nested udta atoms as applicable to the stream instead of globally. Signed-off-by: Nik Johnson <nik@nikjohnson.net> --- libavformat/mov.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)