eworm-de / mpd-notification

Notify about tracks played by mpd
GNU General Public License v3.0
86 stars 23 forks source link

add support for formats other than MP3 #41

Open lukaswrz opened 2 years ago

lukaswrz commented 2 years ago

libavformat supports many more formats than just MP3 (see ffmpeg -formats), so I think it makes sense to avoid checking the MIME type of the file. This means that other widely-used formats such as FLAC and Opus would also be supported by mpd-notification.

If the file can't be recognized by libavformat, the call to avformat_open_input would simply fail and the rest of the program can move on. I have tested this and it works for me without any issues.

I'm curious as to why it's looking up the MIME type in the first place... Am I missing something important here?

eworm-de commented 2 years ago

Hmm, did not know that FLAC and Opus do support embedded cover artwork... Will have to look into this myself, can't remember why I used libmagic to limit support for mp3 files...

fwsmit commented 2 years ago

Hmm, did not know that FLAC and Opus do support embedded cover artwork... Will have to look into this myself, can't remember why I used libmagic to limit support for mp3 files...

It might be a slightly faster way to see if you can load an image, but it doesn't seem neccesary.

lukaswrz commented 2 years ago

It might be a slightly faster way to see if you can load an image

I don't notice any performance difference on my machine (ThinkPad X240).

If anything, the MIME check would only add extra overhead because the file has to be read twice if it's an MP3 file (once to get the MIME type by reading the magic number, and once again to get the cover art with libavformat), regardless of whether or not cover art is present.