From 0519359927f390ce6a752b9c8d40cc75b6acaea8 Mon Sep 17 00:00:00 2001 From: Justin Maggard Date: Wed, 23 Mar 2011 07:20:14 +0000 Subject: [PATCH] * Add support for reading tags from MP4 video files with recent lavf versions. --- metadata.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/metadata.c b/metadata.c index c83534e..926481b 100644 --- a/metadata.c +++ b/metadata.c @@ -795,7 +795,7 @@ GetVideoMetadata(const char * path, char * name) break; } asprintf(&m.frequency, "%u", ctx->streams[audio_stream]->codec->sample_rate); - #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0) + #if LIBAVCODEC_VERSION_INT < (52<<16) asprintf(&m.bps, "%u", ctx->streams[audio_stream]->codec->bits_per_sample); #else asprintf(&m.bps, "%u", ctx->streams[audio_stream]->codec->bits_per_coded_sample); @@ -1439,6 +1439,29 @@ GetVideoMetadata(const char * path, char * name) } } } + #if LIBAVFORMAT_VERSION_INT >= ((52<<16)+(31<<8)+0) + else if( strcmp(ctx->iformat->name, "mov,mp4,m4a,3gp,3g2,mj2") == 0 ) + { + if( ctx->metadata ) + { + AVMetadataTag *tag = NULL; + + //DEBUG DPRINTF(E_DEBUG, L_METADATA, "Metadata:\n"); + while( (tag = av_metadata_get(ctx->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX)) ) + { + //DEBUG DPRINTF(E_DEBUG, L_METADATA, " %-16s: %s\n", tag->key, tag->value); + if( strcmp(tag->key, "title") == 0 ) + m.title = strdup(trim(tag->value)); + else if( strcmp(tag->key, "genre") == 0 ) + m.genre = strdup(trim(tag->value)); + else if( strcmp(tag->key, "artist") == 0 ) + m.artist = strdup(trim(tag->value)); + else if( strcmp(tag->key, "comment") == 0 ) + m.comment = strdup(trim(tag->value)); + } + } + } + #endif video_no_dlna: av_close_input_file(ctx);