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

ogg tags not recognized #250

Closed h67ma closed 1 year ago

h67ma commented 2 years ago

I'm having problems reading tags from ogg files with Vobris or Opus codec, possibly other codecs as well. Most of the tags are not being recognized.

Repro

Logcat output for the mp3 file:

Key: album Value: Da Album
Key: artist Value: The Artist
Key: comment Value: boonooonoonnos
Key: date Value: 2021
Key: encoder Value: LAME3.100
Key: genre Value: Synth-pop
Key: title Value: Mastapiece
Key: track Value: 42
Key: duration Value: 4000
Key: audio_codec Value: mp3
Key: chapter_count Value: 0
Key: filesize Value: 46883

Logcat output for the ogg file:

Key: track Value: 42
Key: duration Value: 4000
Key: audio_codec Value: vorbis
Key: chapter_count Value: 0
Key: filesize Value: 56539

Speculation

I think it might have something to do with the way that ffmpeg outputs tags read from ogg files. Below are examples of ffprobe outputs, for the same two files:

ffprobe -v quiet -print_format json -show_format -show_streams test.mp3
{
    "streams": [
        {
            "index": 0,
            "codec_name": "mp3",
            "codec_long_name": "MP3 (MPEG audio layer 3)",
            "codec_type": "audio",
            "codec_time_base": "1/44100",
            "codec_tag_string": "[0][0][0][0]",
            "codec_tag": "0x0000",
            "sample_fmt": "fltp",
            "sample_rate": "44100",
            "channels": 2,
            "channel_layout": "stereo",
            "bits_per_sample": 0,
            "r_frame_rate": "0/0",
            "avg_frame_rate": "0/0",
            "time_base": "1/14112000",
            "start_pts": 353600,
            "start_time": "0.025057",
            "duration_ts": 57876480,
            "duration": "4.101224",
            "bit_rate": "91077",
            "disposition": {
                "default": 0,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0
            },
            "tags": {
                "encoder": "LAME3.100"
            }
        }
    ],
    "format": {
        "filename": "test.mp3",
        "nb_streams": 1,
        "nb_programs": 0,
        "format_name": "mp3",
        "format_long_name": "MP2/3 (MPEG audio layer 2/3)",
        "start_time": "0.025057",
        "duration": "4.101224",
        "size": "46883",
        "bit_rate": "91451",
        "probe_score": 51,
        "tags": {
            "artist": "The Artist",
            "title": "Mastapiece",
            "comment": "boonooonoonnos",
            "album": "Da Album",
            "genre": "Synth-pop",
            "track": "42",
            "date": "2021"
        }
    }
}

ffprobe -v quiet -print_format json -show_format -show_streams test.ogg
{
    "streams": [
        {
            "index": 0,
            "codec_name": "vorbis",
            "codec_long_name": "Vorbis",
            "codec_type": "audio",
            "codec_time_base": "1/44100",
            "codec_tag_string": "[0][0][0][0]",
            "codec_tag": "0x0000",
            "sample_fmt": "fltp",
            "sample_rate": "44100",
            "channels": 2,
            "channel_layout": "stereo",
            "bits_per_sample": 0,
            "r_frame_rate": "0/0",
            "avg_frame_rate": "0/0",
            "time_base": "1/44100",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 178587,
            "duration": "4.049592",
            "bit_rate": "160000",
            "disposition": {
                "default": 0,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0
            },
            "tags": {
                "ARTIST": "The Artist",
                "TITLE": "Mastapiece",
                "COMMENTS": "boonooonoonnos",
                "ALBUM": "Da Album",
                "DATE": "2021",
                "track": "42",
                "GENRE": "Synth-pop"
            }
        }
    ],
    "format": {
        "filename": "test.ogg",
        "nb_streams": 1,
        "nb_programs": 0,
        "format_name": "ogg",
        "format_long_name": "Ogg",
        "start_time": "0.000000",
        "duration": "4.049592",
        "size": "56539",
        "bit_rate": "111693",
        "probe_score": 100
    }
}

Tag values are stored in a different element of output - for mp3 and most other file formats it's output["format"]["tags"], while for ogg it seems to be output["streams"][0]["tags"].

wseemann commented 2 years ago

@h67ma Can you post a sample file for me to test with?

h67ma commented 2 years ago

Sure, here you go: ffmpeg_meta_retriever_ogg_issue_samples.zip

wseemann commented 2 years ago

@h67ma I found the issue, your research was helpful. I was setting the AV_DICT_MATCH_CASE in av_dict_get which caused my code to ignore metadata values that don't match the key case. Since all your metadata values are upper case it was ignoring them. This will be fixed in the next public release, the fix has been pushed to the main branch. Thanks for the files and good research!

h67ma commented 2 years ago

Thank you for looking into it, I really appreciate it!

wseemann commented 1 year ago

This is fixed in version 1.0.19. Closing this issue.