0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00

demux: improve audio tag merging for OGG files

It's a mess: mp3 files have user tags as global metadata (because the
id3v2 tag is global and there is only 1 stream), while OGG files have it
per-track (because it's per-stream on the lowest level). mpv needs to
try to make something nice out of the mess.

It did so by trying to detect audio-only OGG files, and then copying the
per-stream metadata to the global metadata. Make the heuristic for
detecting this slightly more clever, so it works for files with extra,
unrelated streams, like the awful libavformat cover art hack.

Fixes #5577.
This commit is contained in:
wm4 2018-03-02 12:57:28 +01:00 committed by Jan Ekström
parent ecf4d7a843
commit e4cb6fd0fd

View File

@ -1967,10 +1967,23 @@ void demux_update(demuxer_t *demuxer)
}
}
// Often useful audio-only files, which have metadata in the audio track
// metadata instead of the main metadata (especially OGG).
if (in->num_streams == 1)
mp_tags_merge(demuxer->metadata, in->streams[0]->tags);
// Often for useful audio-only files, which have metadata in the audio
// track metadata instead of the main metadata, but can also have cover
// art metadata (which libavformat likes to treat as video streams).
int astreams = 0;
int astream_id = -1;
int vstreams = 0;
for (int n = 0; n < in->num_streams; n++) {
struct sh_stream *sh = in->streams[n];
if (sh->type == STREAM_VIDEO && !sh->attached_picture)
vstreams += 1;
if (sh->type == STREAM_AUDIO) {
astreams += 1;
astream_id = n;
}
}
if (vstreams == 0 && astreams == 1)
mp_tags_merge(demuxer->metadata, in->streams[astream_id]->tags);
if (in->stream_metadata)
mp_tags_merge(demuxer->metadata, in->stream_metadata);