Determine currently used codec

Discuss client development (or even MPD development if you feel so inclined), ask questions about the client libs, MPD feature requests from client developers, etc...
Post Reply
Adrian
Posts: 4
Joined: June 2nd, 2018, 6:48 am
Contact:

Determine currently used codec

Post by Adrian » June 2nd, 2018, 7:39 am

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.

max
Forum team
Posts: 854
Joined: January 15th, 2013, 3:43 pm

Re: Determine currently used codec

Post by max » June 2nd, 2018, 9:13 am

MPD does not provide that piece of information over its protocol.

Adrian
Posts: 4
Joined: June 2nd, 2018, 6:48 am
Contact:

Re: Determine currently used codec

Post by Adrian » June 2nd, 2018, 10:34 am

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.

max
Forum team
Posts: 854
Joined: January 15th, 2013, 3:43 pm

Re: Determine currently used codec

Post by max » June 2nd, 2018, 1:35 pm

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.

Adrian
Posts: 4
Joined: June 2nd, 2018, 6:48 am
Contact:

Re: Determine currently used codec

Post by Adrian » June 2nd, 2018, 3:32 pm

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.

max
Forum team
Posts: 854
Joined: January 15th, 2013, 3:43 pm

Re: Determine currently used codec

Post by max » June 2nd, 2018, 5:05 pm

Neither M4A nor Ogg is a codec.

Adrian
Posts: 4
Joined: June 2nd, 2018, 6:48 am
Contact:

Re: Determine currently used codec

Post by Adrian » June 2nd, 2018, 6:25 pm

Hi Max

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

Adrian.

Post Reply