[MPlayer-users] Quoting and manipulating variables in mplayer slave mode

David Liontooth lionteeth at cogweb.net
Sat Apr 23 11:50:16 CEST 2011


I use the bash script mplayer-slave to start mplayer in slave mode:

# Set the input configuration file
KEYS=~/.mplayer/slave.conf

# Write the configuration file if needed
if [ ! -f $KEYS ] ; then
echo "# ~/.mplayer/slave.conf
# Special keymap for /usr/local/bin/mplayer-slave
# Edit /usr/local/bin/mplayer-slave to improve this configuration file
# A modified file will not be overwritten; delete the file to get the 
default
# See mplayer -input cmdlist
# Keys not remapped here will keep the values given in 
/etc/mplayer/input.conf

c run "/usr/local/bin/mplayer-slave-check c"    # Check and clean the 
story boundary marks
B run "/usr/local/bin/mplayer-slave-move B"     # Toggle black frames 
tag list
n run "/usr/local/bin/mplayer-slave-move n"     # Move to next tag
p run "/usr/local/bin/mplayer-slave-move p"     # Move to previous tag
s run "/usr/local/bin/mplayer-slave-mark s"     # Mark the start of a 
story boundary
e run "/usr/local/bin/mplayer-slave-mark e"     # Mark the end of a 
story boundary
u run "/usr/local/bin/mplayer-slave-mark u"     # Undo the last story 
boundary mark
q quit" > $KEYS
fi

# Create the pipe
FIFO=~/.mplayer/fifo
if [ ! -p $FIFO ] ; then mkfifo $FIFO ; fi

# Start the player and background it
mplayer -slave -idle -quiet -nocache -input file=$FIFO $DIR/$FIL.$EXT 
-input conf=$KEYS $FIL.$EXT > $TAGFIL &

# Inside the script, I can then OSD-display a bash variable and 
manipulate the string on the fly --
# mandatory quoting for this is single quotes for the bash variable 
inside a double-quoted command:
echo "osd_show_text '${FIL//_/ }' 1000 0" > $FIFO   # Replace underscore 
with space
echo "pausing seek 0 2" > $FIFO ; sleep 1  # Show the file name for a 
second at the beginning

# I can also display property information, but here the quoting 
convention is the opposite --
# it requires double quotes around the variable (along with curly 
brackets) and then single around the command:
echo 'osd_show_property_text "${filename}" 1000 0' > $FIFO ; sleep 1

Is this correct? And there's no way to do on-the-fly string 
manipulations in this second case?

mplayer -slave is a lot of fun, really an incredible tool!

Cheers,
Dave



More information about the MPlayer-users mailing list