0

When I try to play an audio file using avplay on a raspberry pi3 running raspbian jessie, I get the following error.

pi@raspberrypi:~/sounds $ /usr/bin/avplay clip1.wav 
avplay version 11.9-6:11.9-1~deb8u1+rpi1, Copyright (c) 2003-2017 the Libav developers
  built on Apr 26 2017 06:57:28 with gcc 4.9.2 (Raspbian 4.9.2-10)
Could not initialize SDL - Unable to open a console terminal

I'm uncertain how to fix this. A google search on this error message did not turn up much of use.

I've tried ...

pi@raspberrypi:~/sounds $ /usr/bin/avplay -nodisp clip1.wav 
avplay version 11.9-6:11.9-1~deb8u1+rpi1, Copyright (c) 2003-2017 the Libav developers
  built on Apr 26 2017 06:57:28 with gcc 4.9.2 (Raspbian 4.9.2-10)
Could not initialize SDL - Unable to open a console terminal

and

pi@raspberrypi:~/sounds $ unset DISPLAY
pi@raspberrypi:~/sounds $ /usr/bin/avplay -nodisp clip1.wav 
avplay version 11.9-6:11.9-1~deb8u1+rpi1, Copyright (c) 2003-2017 the Libav developers
  built on Apr 26 2017 06:57:28 with gcc 4.9.2 (Raspbian 4.9.2-10)
Could not initialize SDL - Unable to open a console terminal

I installed this like so ...

pi@raspberrypi:~ $ sudo apt-get install libav-tools 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libav-tools is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 287 not upgraded.

pi@raspberrypi:~ $ dpkg -l libav-tools
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                    Version                  Architecture             Description
+++-=======================================-========================-========================-===================================================================================
ii  libav-tools                             6:11.9-1~deb8u1+rpi1     armhf                    Multimedia player, encoder and transcoder
0

Here is a solution:

pi@raspberrypi:~/sounds $ export DISPLAY=:0
pi@raspberrypi:~/sounds $ /usr/bin/avplay clip1.wav 
avplay version 11.9-6:11.9-1~deb8u1+rpi1, Copyright (c) 2003-2017 the Libav developers
  built on Apr 26 2017 06:57:28 with gcc 4.9.2 (Raspbian 4.9.2-10)
[wav @ 0x72400480] max_analyze_duration 5000000 reached
Input #0, wav, from 'samah-clip1.wav':
  Metadata:
    encoder         : Lavf57.71.100
  Duration: 00:00:13.02, bitrate: 352 kb/s
    Stream #0.0: Audio: pcm_u8, 22050 Hz, 2 channels, u8, 352 kb/s
^CALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred f=0/0  
0

A workaround may be to use sudo, e.g. /usr/bin/avplay clip1.wav. This error appears to occur when there's some sort of permissions error with /dev/console and/or /dev/tty* for the current user. sudo short-cuts around that, but isn't a proper fix.

I think the underlying configuration problem could be with PAM or systemd-logind, which are in charge of matching console permissions on login, but I don't know enough to track down the specific issue. (And it's difficult to do without the actual hardware and the fault on hand...) A newer version of Raspbian, either via update or reinstall may help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.