wseemann / FFmpegMediaMetadataRetriever

FFmpegMediaMetadataRetriever provides a unified interface for retrieving frame and meta data from an input media file.
1.72k stars 387 forks source link

Embedded coverart overwrites comment field #263

Open h67ma opened 1 year ago

h67ma commented 1 year ago

Summary

Parsing of comment metadata field yields wrong value if embedded coverart(s) are present.

Repro

val testPath = "/path/to/testfile.ogg"
val mediaInfo = FFmpegMediaMetadataRetriever()
mediaInfo.setDataSource(testPath)
for (meta in mediaInfo.metadata.all)
{
    Log.d("test", "${meta.key} = ${meta.value}");
}

(see attached sample files: ffmpeg_extr_embedded_coverart_comments_bug.zip)

Sample 1: test_no_coverart.ogg

If track has no embedded coverart, comment field extraction works correctly:

...
D/test: COMMENT = boonooonoonnos
...

Sample 2: test_coverart_comment.ogg

If coverart is present, comment field value is overwritten with "Cover (front)":

...
D/test: comment = Cover (front)
...

Sample 3: test_coverart_comments.ogg

Some audio files include a field called comments instead of comment, in which case there will be two values: one coming from embedded coverart "comment", and second coming from comments field:

...
D/test: comments = boonooonoonnos
...
D/test: comment = Cover (front)
...

Sample 4: test_coverart_multiple_comment.ogg

In case when audio file contains multiple embedded coverarts, the last one will replace the comment field value:

...
D/test: comment = Cover (back)
...

Version

1.0.18

Isolation notes

Issue does not reproduce on 1.0.16

Speculation

Looing at the output of ffprobe -v quiet -print_format json -show_format -show_streams test_coverart_comment.ogg, if coverart is present, there exists root["streams"][index]["tags"]["comment"], containing the name of coverart, e.g. "Cover (front)". This is likely the cause of the bug, as the comment key has the same name as the actual comment key.