From 33b5015469e13f5dbd8c4005eda5c93f67ade093 Mon Sep 17 00:00:00 2001 From: Viliam Mateicka Date: Tue, 18 Nov 2008 20:03:00 +0100 Subject: ffmpeg: read tags from AVFormatContext The ffmpeg library provides some of the song metadata in the AVFormatContext struct. Pass it from there to MPD. --- src/decoder/ffmpeg_plugin.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/decoder/ffmpeg_plugin.c b/src/decoder/ffmpeg_plugin.c index e1505e884..0c691ad20 100644 --- a/src/decoder/ffmpeg_plugin.c +++ b/src/decoder/ffmpeg_plugin.c @@ -301,11 +301,22 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input) static bool ffmpeg_tag_internal(struct ffmpeg_context *ctx) { struct tag *tag = (struct tag *) ctx->tag; - - if (ctx->format_context->duration != (int)AV_NOPTS_VALUE) { - tag->time = ctx->format_context->duration / AV_TIME_BASE; - } else { - tag->time = 0; + const AVFormatContext *f = ctx->format_context; + + tag->time = 0; + if (f->duration != (int)AV_NOPTS_VALUE) + tag->time = f->duration / AV_TIME_BASE; + if (f->author[0]) + tag_add_item(tag, TAG_ITEM_ARTIST, f->author); + if (f->title[0]) + tag_add_item(tag, TAG_ITEM_TITLE, f->title); + if (f->album[0]) + tag_add_item(tag, TAG_ITEM_ALBUM, f->album); + + if (f->track > 0) { + char buffer[16]; + snprintf(buffer, sizeof(buffer), "%d", f->track); + tag_add_item(tag, TAG_ITEM_TRACK, buffer); } return true; -- cgit v1.2.3