[MPlayer-users] MPlayer – changing ‘ao=’ codec order in mplayer.conf does not appear to work for per user config?
Jim Cross
jimgcross at gmail.com
Wed Sep 17 09:06:59 CEST 2014
FIXED - well 'fudged' is a more accurate description.
One could argue and say there is a limitation with MPlayer only looking for
an environment value 'HOME' rather than a more robust mechanism to
determine a users 'home' directory....
Running MPlayer with 'env HOME=/var/www' will help MPlayer locate the users
config file without having to edit /etc/mplayer/mplayer.conf. This also
fixes the need to run MPlayer with sudo:
playing_mplayer=subprocess.Popen(['env', 'HOME=/var/www', 'mplayer',
'-slave', '-nocache', '-quiet', '-volume', '60', '-key-fifo-size', '2',
'-input', fifoFile, '-playlist', '
http://tx.whatson.com/icecast.php?i=magic1054.mp3.m3u' ],
stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.STDOUT)
The output run from a browser and 'slave' commands sent to fifo by user pi
on command line in terminal (using config in /var/www/.mplayer with alsa
first in list and the default /etc/mplayer/mplayer.conf) :
User: www-data
Env variables: SERVER_SOFTWARE=lighttpd/1.4.31 SERVER_NAME=192.168.1.8
GATEWAY_INTERFACE=CGI/1.1 SERVER_PROTOCOL=HTTP/1.1 SERVER_PORT=80
SERVER_ADDR=0.0.0.0 REQUEST_METHOD=GET REDIRECT_STATUS=200
REQUEST_URI=/cgi-bin/test.py REMOTE_ADDR=192.168.1.7 REMOTE_PORT=40681
CONTENT_LENGTH=0 SCRIPT_FILENAME=/var/www/cgi-bin/test.py
SCRIPT_NAME=/cgi-bin/test.py DOCUMENT_ROOT=/var/www/ HTTP_HOST=192.168.1.8
HTTP_CONNECTION=keep-alive HTTP_REFERER=http://192.168.1.8/test.html
HTTP_ACCEPT=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_USER_AGENT=Mozilla/5.0 (Linux; U; Android 4.0.4; en-gb; SonyST21i
Build/11.0.A.4.22) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0
Mobile Safari/534.30 HTTP_ACCEPT_ENCODING=gzip,deflate
HTTP_ACCEPT_LANGUAGE=en-GB, en-US HTTP_ACCEPT_CHARSET=utf-8, iso-8859-1,
utf-16, *;q=0.7 HTTP_X_WAP_PROFILE=
http://uaprof.sonymobile.com/ST21iR402.xml
home dir is: /var/www
test.py:
Resolving tx.whatson.com for AF_INET...
Connecting to server tx.whatson.com[91.193.246.140]: 80...
Resolving ICY-E-05.sharp-stream.com for AF_INET...
Connecting to server ICY-E-05.sharp-stream.com[91.193.246.144]: 80...
Cache size set to 0 KBytes
MPlayer svn r34540 (Debian), built with gcc-4.6 (C) 2000-2012 MPlayer Team
Terminal type `unknown' is not defined.
Playing http://icy-e-05.sharp-stream.com:80/magic1054.mp3.
Resolving icy-e-05.sharp-stream.com for AF_INET...
Connecting to server icy-e-05.sharp-stream.com[91.193.246.144]: 80...
Name : Magic
Genre : Various
Public : no
Bitrate: 112kbit/s
Cache size set to 0 KBytes
Cannot seek backward in linear streams!
ICY Info: StreamTitle='';StreamUrl='magic.co.uk';
Audio only file format detected.
==========================================================================
Requested audio codec family [mpg123] (afm=mpg123) not available.
Enable it at compilation.
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
libavcodec version 53.35.0 (external)
Mismatching header version 53.32.2
AUDIO: 44100 Hz, 2 ch, floatle, 112.0 kbit/3.97% (ratio: 14000->352800)
Selected audio codec: [ffmp3float] afm: ffmpeg (FFmpeg MPEG layer-3 audio)
==========================================================================
AO: [alsa] 44100Hz 2ch floatle (4 bytes per sample)
Video: no video
Starting playback...
[A [KVolume: 71 %
[A [K
Exiting... (Quit)
On Tue, Sep 16, 2014 at 9:31 AM, Jim Cross <jimgcross at gmail.com> wrote:
> Thanks both for your advice and now modified the test script as follows
> and the outputs show a more clear view as to what is not being set I think.
> It looks like lighttpd does not set the 'HOME' env var so will head over to
> lighttpd support and ask if setting the HOME env is possible as I can't
> find any examples on www.
>
> As for the fifo, yes I believe it is being blocked when running test.py
> via browser. Running test.py on command line logged in as www-data or pi is
> OK and the fifo works. :
>
> test.py:
> #!/usr/bin/env python
>
> import subprocess
> import select
>
> from os.path import expanduser
> home = expanduser("~")
>
> fifoFile = 'file=/run/shm/mpcontrol'
>
> environmentVariables = subprocess.check_output(['printenv'])
> whoAmI = subprocess.check_output(['whoami'])
>
> playing_mplayer=subprocess.Popen(['mplayer', '-slave', '-nocache',
> '-quiet', '-volume', '60', '-key-fifo-size', '2', '-input', fifoFile,
> '-playlist', 'http://tx.whatson.com/icecast.php?i=magic1054.mp3.m3u' ],
> stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.STDOUT)
>
> mpText=""
> counting = 1
> while counting < 300:
> counting = counting + 1
> if 'Starting playback...' in mpText : break
> while any(select.select([playing_mplayer.stdout.fileno()], [], [],
> 0.01)):
> mplayerResponse = playing_mplayer.stdout.readline()
> if (mplayerResponse is None) or (len(mplayerResponse) == 0) :
> mplayerResponse = ""
> if mplayerResponse != "":
> print mplayerResponse
> mpText = mpText+mplayerResponse+'<br>'
> break
>
> with open('/var/www/error_log','a',0) as g:
> g.write('User: '+whoAmI+'<br>\nEnv variables:
> '+environmentVariables+'<br>\nhome dir is:
> '+home+'<br>\ntest.py:<br>\n'+str(mpText)+'<br>\n')
> g.close()
>
> Outputs are as follows, first set run from a browser, the second set run
> from command line logged in as www-data:
>
> User: www-data
> Env variables: SERVER_SOFTWARE=lighttpd/1.4.31 SERVER_NAME=192.168.1.8
> GATEWAY_INTERFACE=CGI/1.1 SERVER_PROTOCOL=HTTP/1.1 SERVER_PORT=80
> SERVER_ADDR=0.0.0.0 REQUEST_METHOD=GET REDIRECT_STATUS=200
> REQUEST_URI=/cgi-bin/test.py REMOTE_ADDR=192.168.1.5 REMOTE_PORT=60006
> CONTENT_LENGTH=0 SCRIPT_FILENAME=/var/www/cgi-bin/test.py
> SCRIPT_NAME=/cgi-bin/test.py DOCUMENT_ROOT=/var/www/ HTTP_HOST=192.168.1.8
> HTTP_CONNECTION=keep-alive
> HTTP_ACCEPT=text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
> HTTP_USER_AGENT=Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36
> (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36 HTTP_REFERER=
> http://192.168.1.8/test.html HTTP_ACCEPT_ENCODING=gzip,deflate,sdch
> HTTP_ACCEPT_LANGUAGE=en-GB,en-US;q=0.8,en;q=0.6
> home dir is: /var/www
> test.py:
> Cannot find HOME directory.
> Resolving tx.whatson.com for AF_INET...
> Connecting to server tx.whatson.com[91.193.246.140]: 80...
> Resolving ICY-E-02.sharp-stream.com for AF_INET...
> Connecting to server ICY-E-02.sharp-stream.com[193.27.42.230]: 80...
>
> Cache size set to 0 KBytes
> MPlayer svn r34540 (Debian), built with gcc-4.6 (C) 2000-2012 MPlayer Team
> Terminal type `unknown' is not defined.
>
> Playing http://icy-e-02.sharp-stream.com:80/magic1054.mp3.
> Resolving icy-e-02.sharp-stream.com for AF_INET...
> Connecting to server icy-e-02.sharp-stream.com[193.27.42.230]: 80...
>
> Name : Magic 105.4
> Genre : Various
> Public : no
> Bitrate: 112kbit/s
> Cache size set to 0 KBytes
> Cannot seek backward in linear streams!
>
> ICY Info: StreamTitle='Shania Twain - Man I Feel Like A Woman';StreamUrl='
> magic.co.uk';
> Audio only file format detected.
> ==========================================================================
> Requested audio codec family [mpg123] (afm=mpg123) not available.
> Enable it at compilation.
> Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
> libavcodec version 53.35.0 (external)
> Mismatching header version 53.32.2
> AUDIO: 44100 Hz, 2 ch, floatle, 112.0 kbit/3.97% (ratio: 14000->352800)
> Selected audio codec: [ffmp3float] afm: ffmpeg (FFmpeg MPEG layer-3 audio)
> ==========================================================================
> AO: [alsa] 44100Hz 2ch floatle (4 bytes per sample)
> Video: no video
> Starting playback...
>
>
> **************************
> **
> **************************
>
>
> User: www-data
> Env variables: MAIL=/var/mail/www-data SSH_CLIENT=192.168.1.5 60296 22
> USER=www-data SHLVL=1 HOME=/var/www SSH_TTY=/dev/pts/0 LOGNAME=www-data
> _=printenv TERM=xterm
> PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
> DISPLAY=localhost:10.0 LANG=en_GB.UTF-8
> LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:
> SHELL=/bin/sh PWD=/home/pi SSH_CONNECTION=192.168.1.5 60296 192.168.1.8 22
> home dir is: /var/www
> test.py:
> Resolving tx.whatson.com for AF_INET...
> Connecting to server tx.whatson.com[91.193.246.9]: 80...
> Resolving ICY-E-05.sharp-stream.com for AF_INET...
> Connecting to server ICY-E-05.sharp-stream.com[91.193.246.144]: 80...
>
> Cache size set to 0 KBytes
> MPlayer svn r34540 (Debian), built with gcc-4.6 (C) 2000-2012 MPlayer Team
>
> Playing http://icy-e-05.sharp-stream.com:80/magic1054.mp3.
> Resolving icy-e-05.sharp-stream.com for AF_INET...
> Connecting to server icy-e-05.sharp-stream.com[91.193.246.144]: 80...
>
> Name : Magic
> Genre : Various
> Public : no
> Bitrate: 112kbit/s
> Cache size set to 0 KBytes
> Cannot seek backward in linear streams!
>
> ICY Info: StreamTitle='Toni Braxton - Unbreak My Heart';StreamUrl='
> magic.co.uk';
> Audio only file format detected.
> ==========================================================================
> Requested audio codec family [mpg123] (afm=mpg123) not available.
> Enable it at compilation.
> Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
> libavcodec version 53.35.0 (external)
> Mismatching header version 53.32.2
> AUDIO: 44100 Hz, 2 ch, floatle, 112.0 kbit/3.97% (ratio: 14000->352800)
> Selected audio codec: [ffmp3float] afm: ffmpeg (FFmpeg MPEG layer-3 audio)
> ==========================================================================
> AO: [alsa] 44100Hz 2ch floatle (4 bytes per sample)
> Video: no video
> Starting playback...
>
> On Tue, Sep 16, 2014 at 12:39 AM, Reimar Döffinger <
> Reimar.Doeffinger at gmx.de> wrote:
>
>> On 15.09.2014, at 21:25, Jim Cross <jimgcross at gmail.com> wrote:
>> > The problem or issue(s) (or bug) with this I believe is, MPlayer can not
>> > find the users config file. This can be resolved by editing the
>> > /etc/mplayer/mplayer.conf file to point to a config file (not ideal).
>>
>> You (unintentionally) it seems explicitly undefined HOME and did not set
>> MPLAYER_HOME.
>> MPlayer will not try to dig into your system internals just to work
>> around this, if you tell it there is no home directory by undefining HOME
>> it will just accept that.
>>
>> > The
>> > second issue this appears to have, is with the fifio - mplayer does not
>> > read the fifo (data stays in fifo and mplayer does not change volume for
>> > example ) unless I run mplayer with sudo, then it appears to work OK.
>> > Currenty, I use the following fifo:
>> >
>> > -input file=/run/shm/mpcontrol
>>
>> I would suggest starting with a simpler/saner location like /tmp.
>>
>> > Even setting the perms so anyone can change the fifo as follows, doesn't
>> > work:
>> > 'sudo chmod 777 /run/shm/mpcontrol'
>> >
>> > Checking:
>> > $ ls -al /run/shm/mpcontrol
>> > prwxrwxrwx 1 www-data www-data 0 Sep 13 11:15 /run/shm/mpcontrol
>> >
>> > I have tried changing owner of fifo to pi:pi and root:root with the same
>> > response, i.e. does not read fifo unless mplayer is run with 'sudo'.
>>
>> You say "it does not read it". That means it doesn't actually print any
>> error?
>> In that case it's likely it does not read it because it is blocked.
>> One reason can be not reading its stdout, but there are other options
>> like permission errors causing it to use a different ao that blocks it in
>> the end etc.
>> _______________________________________________
>> MPlayer-users mailing list
>> MPlayer-users at mplayerhq.hu
>> https://lists.mplayerhq.hu/mailman/listinfo/mplayer-users
>>
>
>
More information about the MPlayer-users
mailing list