User avatar
dasmanul
Posts: 502
Joined: Wed Sep 30, 2015 10:20 am
Location: Frankfurt, Germany

[SOLVED] mpd on jessie: can't play m4a files, mp3's work

Mon Oct 12, 2015 5:45 pm

New Raspberry 2 with Hifiberry DAC+ for a soundcard here. As stated in the subject, mp3's play just fine via mpd, but m4a's won't. Here's what the mpd log file says when I try to play m4a files:

Code: Select all

Oct 12 18:50 : player: played "http://10.0.0.16:9790/minimserver/*/Manuel/Music/Al*20Andaluz*20Project/Deus*20et*20Diabolus/01*20Morena.m4a"
Oct 12 18:50 : ffmpeg/mov,mp4,m4a,3gp,3g2,mj2: max_analyze_duration 5000000 reached
Oct 12 18:50 : alsa_output: Failed to open "My ALSA Device" [alsa]: Error opening ALSA device "default" (snd_pcm_hw_params): Invalid argument
Oct 12 18:50 : output: Failed to open audio output
Oct 12 18:50 : player: problems opening audio device while playing "http://10.0.0.16:9790/minimserver/*/Manuel/Music/Al*20Andaluz*20Project/Deus*20et*20Diabolus/01*20Morena.m4a"
The "failed to open ... device" message lets me suspect some gross oversight on my part, but since mp3's play just fine I guess the sound card is set up correctly.

Do I need any additional components/libraries so mpd can play m4a files? I have libfaad2, libmp4v2-2, and libavcodec56 installed, anything else I need?

Thanks in advance for any help!
Last edited by dasmanul on Sat Oct 17, 2015 10:08 am, edited 1 time in total.

emk2203
Posts: 18
Joined: Thu Aug 20, 2015 9:14 am

Re: mpd on raspbian jessie: can't play m4a files, mp3's work

Tue Oct 13, 2015 11:06 am

Maybe you have embedded pictures in the .m4a which ffmpeg doesn't like. If this file shows a picture in iTunes, you have a picture in it.

Try decoding it with ffmpeg only to see if the hiccup occurs. If it does, retry with the additional ffmpeg option of `vcodec=mjpeg`. If ffmpeg decodes now, you need this option passed to ffmpeg for your .m4a files.

User avatar
dasmanul
Posts: 502
Joined: Wed Sep 30, 2015 10:20 am
Location: Frankfurt, Germany

Re: mpd on raspbian jessie: can't play m4a files, mp3's work

Tue Oct 13, 2015 11:57 am

Thank you emk2203, that's very helpful! I (think I) do indeed have embedded pictures in (most of) my m4a files.

As for your suggestion: I don't have ffmpeg installed and jessie doesn't seem to offer it for installation - there's only libav-tools available. Is there a similar option for that (avplay I guess?) or should I switch to/install ffmpeg?

User avatar
dasmanul
Posts: 502
Joined: Wed Sep 30, 2015 10:20 am
Location: Frankfurt, Germany

Re: mpd on raspbian jessie: can't play m4a files, mp3's work

Tue Oct 13, 2015 5:27 pm

Seems to be a red herring: I tried with an m4a file without embedded images (checked via mp4art from package mp4v2-utils) and that won't play either (same symptoms). Strangely, the same files play fine on my other Pi (model B) which is wheezy based but apart from that has a similar setup.

I still feel like I'm overlooking something obvious here. Any hints where to look next?

emk2203
Posts: 18
Joined: Thu Aug 20, 2015 9:14 am

Re: mpd on raspbian jessie: can't play m4a files, mp3's work

Tue Oct 13, 2015 6:25 pm

Does avplay play the file? You can open a ssh session with

Code: Select all

ssh -X -l pi raspberrypi, and use avplay to play the file.
My RPi 2 with Jessie plays sample audio m4a's (from bakeraudio) alright in this setup.

User avatar
dasmanul
Posts: 502
Joined: Wed Sep 30, 2015 10:20 am
Location: Frankfurt, Germany

Re: mpd on raspbian jessie: can't play m4a files, mp3's work

Thu Oct 15, 2015 7:37 am

Thanks for your help, emk2203. I gave it a short try yesterday with one of my own m4a' and it wouldn't play. I'll tray again with one of the files from bakeraudio (we're talking about http://www.bakeraudio.org/sample-audio-recordings.html, aren't we?) to make sure it's actually a setup/installation issue and not just a matter of the wrong file. I'll report back here, but it might be a couple of days before I get around to trying this.

User avatar
dasmanul
Posts: 502
Joined: Wed Sep 30, 2015 10:20 am
Location: Frankfurt, Germany

Re: mpd on raspbian jessie: can't play m4a files, mp3's work

Fri Oct 16, 2015 5:13 pm

Update: I tried again and avplay now plays both the sample m4a's and my own files, even those with embedded pictures. Didn't change anything, at least not wittingly, so I don't know why it works now. Possibly I was mistaken that it didn't work on my last try (had started avplay from another room and then went over to check whether it was playing, maybe I was just too slow...).

However, mpd still refuses to play the files and still gives the same error message. Any more thoughts anybody?

User avatar
dasmanul
Posts: 502
Joined: Wed Sep 30, 2015 10:20 am
Location: Frankfurt, Germany

Re: mpd on raspbian jessie: can't play m4a files, mp3's work

Sat Oct 17, 2015 10:07 am

Problem solved! It turned out to be some basic error on my part, as suspected. The solution was to uncomment the line

Code: Select all

        device          "hw:0,0"        # optional
from the audio_output section of the default /etc/mpd.conf shipped with jessie's mpd. I hadn't thought of that before, since the line was marked as optional and mp3 files worked, so I thought audio output should be configured correctly. A web search for "snd_pcm_hw_params invalid argument" then led me to this thread on the ODROID forum where somebody had a similar problem.

For reference, the complete audio_output section of my /etc/mpd.conf now looks like this:

Code: Select all

audio_output {
        type            "alsa"
        name            "My ALSA Device"
        device          "hw:0,0"        # optional
#       mixer_type      "hardware"      # optional
#       mixer_device    "default"       # optional
        mixer_control   "Digital"               # optional
#       mixer_index     "0"             # optional
}
Big thanks to everybody who tried to help me here!

Return to “Troubleshooting”