Page 1 of 1

Determine currently used codec

Posted: June 2nd, 2018, 7:39 am
by Adrian
Hi

I am writing a C++ program and would like to determine the name of the codec/audio type (e.g. mp3, flac) of the currently playing/paused audio, which could be an audio file or a stream. I am using libmpdclient, but I could also query MPD directly.

The goal is simply to display the current audio type on a small OLED display.

Thanks

Adrian.

Re: Determine currently used codec

Posted: June 2nd, 2018, 9:13 am
by max
MPD does not provide that piece of information over its protocol.

Re: Determine currently used codec

Posted: June 2nd, 2018, 10:34 am
by Adrian
Hi Max

Thanks for the reply.

I was asked if I could include the audio type in my OLED display program, and looking around it appears to be a popular item of information (Volumio displays it in the Web UI, but not for radio, and I have seen it in images of LCD displays for MPD-based music players). Maybe they are extracting it from the file name.

Adrian.

Re: Determine currently used codec

Posted: June 2nd, 2018, 1:35 pm
by max
From the file name? So what do they tell you if "*.m4a" is played? Is the codec AAC or ALAC?
Let alone "*.ogg" which is a container format and may contain Vorbis, FLAC or Opus - and other container formats which are less common in audio-only space.

Re: Determine currently used codec

Posted: June 2nd, 2018, 3:32 pm
by Adrian
Hi Max

I just played a ".m4a" file in Volumio, and it displayed "M4A" on a file icon. I also played a ".ogg" file and it displayed an "Ogg" graphic.

I have also just tried a program called mediainfo, that reports the audio format of files and streams. I can probably run that with the location returned by mpd_song_get_uri() and extract the audio fromat from the report.

Adrian.

Re: Determine currently used codec

Posted: June 2nd, 2018, 5:05 pm
by max
Neither M4A nor Ogg is a codec.

Re: Determine currently used codec

Posted: June 2nd, 2018, 6:25 pm
by Adrian
Hi Max

The mediainfo program reports the audio format contained in .m4a and .ogg, and so should be fine for my use.

Adrian.