Comment 0 for bug 697655

Revision history for this message
era (era) wrote :

Binary package hint: mplayer

Running mplayer in a loop is impossible because it consumes standard input even when invoked just to batch convert a file.

Consider a script like:

find . -type f |
while read file; do
 echo "# $file"
  mplayer -vc null -vo null -ao pcm:file="$file.wav" "$file"
done

This will fail mysteriously with "No bind found for key 'O'" warnings etc because apparently mplayer is eating some of the output from the find command as if the user were using it interactively and pressing keys to resize the display etc. As an additional symptom, the output from the echo will mysteriously have chopped file names.

As a workaround, the small sample script above can be fixed by adding a redirection </dev/null to the mplayer command line. Constructing the loop differently (e.g. to run mplayer from within find with -exec) is another possible workaround.

There are several threads about this in Google but none I have found actually correctly diagnosed and corrected this problem.

There is a simple ioctl to find out when a program is invoked with standard input connected to a terminal; the "test -t 0" command does this in a shell script. mplayer should leave standard input alone if it is not connected to a terminal.