diff options
author | Viliam Mateicka <the.metyl@gmail.com> | 2008-11-18 20:03:00 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-11-18 20:03:00 +0100 |
commit | 33b5015469e13f5dbd8c4005eda5c93f67ade093 (patch) | |
tree | 6d1614846e1e4056d7780077ab0666362c6255c0 /src | |
parent | eac4ed2241f11eb9cde051a7c6a1c193c96f9a89 (diff) | |
download | mpd-33b5015469e13f5dbd8c4005eda5c93f67ade093.tar.gz mpd-33b5015469e13f5dbd8c4005eda5c93f67ade093.tar.xz mpd-33b5015469e13f5dbd8c4005eda5c93f67ade093.zip |
ffmpeg: read tags from AVFormatContext
The ffmpeg library provides some of the song metadata in the
AVFormatContext struct. Pass it from there to MPD.
Diffstat (limited to 'src')
-rw-r--r-- | src/decoder/ffmpeg_plugin.c | 21 |
1 files changed, 16 insertions, 5 deletions
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; |