I have a script for playing movies through mplayer, for which I am attempting to include automatic conversion of 3D to 2D. Here is the relevant cmd line as it appears in the script
mplayer -fs "${g[$i]}" -ss $f "${d%.*}".* -hardframedrop -nocorrect-pts -identify &>> log.txt
This does not render to 2D even though "${g[$i]}" has the needed option
echo "${g[$i]}"
-vo gl:stereo=3
But if I modify the cmd line to show the option directly, the movie is shown in 2D
mplayer -fs -vo gl:stereo=3 -ss $f "${d%.*}".* -hardframedrop -nocorrect-pts -identify &>> log.txt
The problem seems to be that mplayer interprets the option as a filename when delivered via ${g[$i]}, thus from log.txt
Playing -vo gl:stereo=3 .
File not found: ' -vo gl:stereo=3 '
Failed to open -vo gl:stereo=3 .
How can I prevent this?
You are passing " -vo gl:stereo=3 "
which is indeed invalid. You should be passing "-vo"
followed by "gl:stereo=3"
. In other words, it should be passed as two separate arguments without the leading and trailing spaces.
The easiest workaround to make this happen is to skip the quotes around ${g[$i]}
:
mplayer -fs ${g[$i]} -ss $f "${d%.*}".* -hardframedrop -nocorrect-pts -identify &>> log.txt
The more robust workaround would be to store the arguments separately in an array, e.g. opts=("-vo" "gl:stereo=3")
and using "${opt[@]}"
, but Bash does not support multidimensional arrays so this may require some deeper changes to your script.