When I run the below script mplayer
gives the below error and doesn't continue the while loop after pressing return. if I replace mplayer
with mpv
it works. I have to use mplayer, as mpv
doesn't support the video formats I need to play.
I suspect the problem is related to file descriptor redirection, but I had to do that to get user input to work in a while loop with piped data from find
.
Purpose
The goal of the script is I want to play each file in a directory, and after watching the video it should prompt me for what to do with the file. E.g. delete, rename, move.
Question
Can anyone see what the problem is, or perhaps how to work around it?
#!/usr/bin/bash
exec 3<&0 # redirect std input to a different file descriptor
find . -maxdepth 1 -type f -name "*" | while read f; do
mplayer -really-quiet -msglevel all=-1 "$f"
echo $f
printf "What to do: "
IFS= read -r -u3 opt
done
exec 3<&- # Close fd3
The error is
do_connect: could not connect to socket
connect: No such file or directory
Failed to open VDPAU backend libvdpau_va_gl.so: cannot open shared object file: No such file or directory
Assertion 'm' failed at pulse/thread-mainloop.c:175, function pa_threaded_mainloop_lock(). Aborting.