summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-03-02 12:57:28 +0100
committerJan Ekström <jeebjp@gmail.com>2018-03-03 02:38:01 +0200
commite4cb6fd0fd95533f5ef353e18decf1a9eec3c28c (patch)
tree406a8fe541435e20a1f1ae565196f29cc6c178a9
parentecf4d7a843d55cdd2979f79d36e6f202a82cba5b (diff)
downloadmpv-e4cb6fd0fd95533f5ef353e18decf1a9eec3c28c.tar.bz2
mpv-e4cb6fd0fd95533f5ef353e18decf1a9eec3c28c.tar.xz
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.
-rw-r--r--demux/demux.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/demux/demux.c b/demux/demux.c
index 7b8faa0c01..c454286fda 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -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);