Commit 33b50154 authored by Viliam Mateicka's avatar Viliam Mateicka Committed by Max Kellermann

ffmpeg: read tags from AVFormatContext

The ffmpeg library provides some of the song metadata in the AVFormatContext struct. Pass it from there to MPD.
parent eac4ed22
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment