[MPlayer-users] mplayer fails when invoked from at command

Bertie Coopersmith bertie at coopersmith.demon.co.uk
Thu Nov 16 19:19:50 CET 2006


Here follows my interactive script which works fine:
====================================================
#!/bin/bash

#        ------------- ripreal --------------

cd /c/recordings
echo "RealAudio streams

"
nl RealAudioStreams > /tmp/RealAudioStreams 
cat /tmp/RealAudioStreams
echo -n "
Enter the item number to rip: "
read STREAMNUMBER
set `sed -n ${STREAMNUMBER}p RealAudioStreams`
URL="$1"
echo "`date '+%a %H%M'` Starting to rip
 $URL" > /dev/console
if 
[ "A$2" = A ] 
then
mplayer "$URL" -ao pcm -vc null -vo null -ao pcm:fast 
else 
let "DURN=60*$2+30"
timeout -$DURN mplayer  "$URL" -ao pcm -vc null -vo null -ao pcm:fast 
fi

# Convert to Sample rate 8000 samples/sec, 8Kz, unsigned 8-bit samples, Mono:-
echo "Converting .wav file to 8KHz, 8-bit samples, mono"
 sox audiodump.wav -t wav -r 8000 -u -b -c 1 ofile.wav 
rm -f audiodump.wav 
echo "`date '+%a %H%M'` converted to /c/recordings/ofile.wav" > /dev/console
stty sane
================================================================
Some comments: 
The file RealAudioStreams is my personal playlist library. The script does
line numbering so each line then has the format:
STREAMNUMBER   URL   Programme_Duration_in_Minutes.
In case EOF is not detected in the stream the script sets a maximum duration
of DURN seconds.

============================================================ 
Here follows the script riprealbk invoked via the at command. It fails. The 
-v and -msglevel flags in the mplayer command were added to get a debugging
trace - See below.
  
#!/bin/sh

#        ------------- riprealbk --------------
#        The non interactive (BacKground) version of ripreal
#        Invoked by 'rr' via the 'at' command.
#        DURN, URL and BASE  are exported by rr.
  
cd /c/recordings
# kill any process (probably mplayer) which may be holding the rtc device open:-
fuser -k /dev/rtc 
rm -f audiodump.wav 

timeout -$DURN mplayer -v -msglevel all=9 "$URL" -ao pcm -vc null -vo null -ao pcm:fast 

# Convert to Sample rate 8000 samples/sec, 8Kz, unsigned 8-bit samples, Mono:-
 sox audiodump.wav -t wav -r 8000 -u -b -c 1 ofile.wav 
speexenc ofile.wav $BASE.spx
rm -f ofile.wav
==============================================================
 
The 'at' command is itself generated from the following script:-

#!/bin/sh

#        ------------- rr --------------

cd /c/recordings
echo "RealAudio streams

"
nl RealAudioStreams > /tmp/RealAudioStreams 
cat /tmp/RealAudioStreams
echo -n "
Enter the item number to rip: "
read STREAMNUMBER
set `sed -n ${STREAMNUMBER}p RealAudioStreams`
URL="$1"
let "DURN=60*$2+30"
echo -n "
Enter the .spx basename: "
read BASE
echo -n "
Enter time to start the run (HHMM): "
read STARTAT
export URL DURN BASE
at -f  /usr/local/bin/riprealbk $STARTAT 
==================================================
 
Here is the trace which 'at' returns as a mail message from root:-
Return-Path: <root at acerp3.sil>
Date: Thu, 16 Nov 2006 14:31:38 GMT
From: root at acerp3.sil
Subject: Output from your job       23
To: root at acerp3.sil
Status: R

MPlayer 1.0pre8-3.3.6 (C) 2000-2006 MPlayer Team
CPU: Intel Pentium III Katmai/Pentium III Xeon Tanner (Family: 6, Model: 7, Stepping: 3)
CPUflags:  MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 0
Compiled with runtime CPU detection.

Adding file rtsp://rmv8.bbc.net.uk/radio4/arts/book_week_fri.ra
this_opt = option: ao
Checking ao=pcm
this_opt = option: vc
Checking vc=null
this_opt = option: vo
Checking vo=null
this_opt = option: ao
Checking ao=pcm:fast
Config pushed level is now
2                                                       
Config pushed level is now 3
Setting ao=pcm
Setting vc=null
Setting vo=null
Setting ao=pcm:fast
get_path('codecs.conf') -> '/root/.mplayer/codecs.conf'
Reading /root/.mplayer/codecs.conf: Can't open '/root/.mplayer/codecs.conf': No such file or directory
Reading /etc/codecs.conf: Can't open '/etc/codecs.conf': No such file or directory
Using built-in default codecs.conf.
CommandLine: '-v' '-msglevel' 'all=9' 'rtsp://rmv8.bbc.net.uk/radio4/arts/book_week_fri.ra' '-ao' 'pcm' '-vc' 'null' '-vo' 'null' '-ao' 'pcm:fast'
init_freetype
get_path('font/font.desc') -> '/root/.mplayer/font/font.desc'
font: can't open file: /root/.mplayer/font/font.desc
font: Reading section: [info]
font: Reading section: [files]
RAW: /usr/share/mplayer/font//cp1250-a.raw  5104 x 38, 256 colors
RAW: /usr/share/mplayer/font//cp1250-b.raw  5104 x 38, 256 colors
font: Reading section: [characters]
font: Reading section: [files]
RAW: /usr/share/mplayer/font//osd-mplayer-a.raw  536 x 32, 256 colors
RAW: /usr/share/mplayer/font//osd-mplayer-b.raw  536 x 32, 256 colors              
font: Reading section: [characters]
font: resampling alpha by factor 0.750 (192) DONE!
font: resampling alpha by factor 0.750 (192) DONE!
Font /usr/share/mplayer/font/font.desc loaded successfully! (233 chars)
Using MMX (with tiny bit MMX2) Optimized OnScreenDisplay
Using Linux hardware RTC timing (1024Hz).
Terminal type `unknown' is not defined.
get_path('input.conf') -> '/root/.mplayer/input.conf'
Can't open input config file /root/.mplayer/input.conf: No such file or directory
Can't open input config file /etc/input.conf: No such file or directory
Falling back on default (hardcoded) input config
get_path('book_week_fri.ra.conf') -> '/root/.mplayer/book_week_fri.ra.conf'

[[[init getch2]]]

Playing rtsp://rmv8.bbc.net.uk/radio4/arts/book_week_fri.ra.
get_path('sub/') -> '/root/.mplayer/sub/'
STREAM_RTSP, URL: rtsp://rmv8.bbc.net.uk/radio4/arts/book_week_fri.ra
Filename for url is now
rtsp://rmv8.bbc.net.uk/radio4/arts/book_week_fri.ra
Filename for url is now
rtsp://rmv8.bbc.net.uk/radio4/arts/book_week_fri.ra
Resolving rmv8.bbc.net.uk for AF_INET...
Connecting to server rmv8.bbc.net.uk[212.58.224.140]: 554...
Cache size set to 640 KBytes                                                       
STREAM: [realrtsp] rtsp://rmv8.bbc.net.uk/radio4/arts/book_week_fri.ra
STREAM: Description: RealNetworks rtsp streaming
STREAM: Author: Roberto Togni, xine team
STREAM: Comment: ported from xine
CACHE_PRE_INIT: 0 [0] 0  pre:131072  eof:0  
Cache fill:  0.00% (0 bytes)   
*** uninit(0x48)

[[[uninit getch2]]]
Config poped level=2
Config poped level=1

*** uninit(0x80)
vo: x11 uninit called but X11 not inited..

Exiting... (End of file)
max framesize was 0 bytes

====================================================
Comments: The warning 
Terminal type `unknown' is not defined.
puzzles me, especially as if the run had continued beyond the first outputting
of the Cache fill percentage, then that output string would have contained
a carriage return character. OTOH the run still aborts at the same point (I
think) even when I suppress output by omitting '-v' and using '-msglevel all=-1'.
  
That warning only occurs with the at-invoked script (riprealbk), never with the interactive (ripreal) script but note that its last line, 'stty sane' seems to
be necessary.

Bertie Coopersmith




More information about the MPlayer-users mailing list