I am trying to get some information out of mplayer. I want to know the length of a video file. I used "-identify" switch it returns a whole bunch of information including something called "ID_LENGTH" which is exactly what I need. Here is what I do in the bash script. (I pass the name of the video file as an argument to the script)
mplayer -identify "$1" 2> /dev/null | grep "ID_LENGTH" > /tmp/out.$$
cat /tmp/out.$$ | cut -d"=" -f2,2
This actually returns the value that I need to get, but the problem is that I need to stop mplayer by hand. The output when I run the script should be the length of the file, without really running the file, so we should exit from mplayer as soon as we get "ID_LENGTH" field so that the script will continue and the length of the file will be outputed on the stdout.
Thanx in advance