Log in

View Full Version : import crop values to shell script


lpn1160
9th August 2006, 23:03
I wrote this little script, but what I would like to do is get the crop values from mplayers -vf cropdetect and put those values in the script. Something like this

mplayers $1 -vf cropdetect
[CROP] Crop area: X: 1..462 Y: 43..432 (-vf crop=448:464:8:8).0

my script:

if [ -z "$1" ]; then
echo "Usage: No inputfile outputfiles <file> [<file> ...]"
exit 1
fi

mplayer $1 -hardframedrop -vc dummy -vo null -ao pcm:file=audio.wav ; normalize --peak -v -T 0.2 audio.wav ; oggenc -q 3.5 audio.wav ; mencoder $1 -o $2.avi -of avi -ovc lavc -ffourcc XVID -lavcopts vcodec=mpeg4:vbitrate=1500:vmax_b_frames=2:mpeg_quant:mbd=1:keyint=150:v4mv -vf ivtc,crop=448:464:8:8,scale=512:384 -nosound -ofps 24000/1001 -sws 9 ; mkvmerge -o $2.mkv $2.avi audio.ogg && rm $2.avi ; rm audio.ogg ; rm audio.wav
clear
exit 0
any insight would be well appreciated, BTW, I just barely get by on shell scripting, so if this needs any perl, or awk just try and point me to a good guide as I have just started reading up on them and am really weak

Thanks all sooooo much

DoctorEnsGabe
12th August 2006, 03:36
Pipe the output of mplayers through the command 'cut' to chop off all of the data surrounding what you need.

It would end up being something like this:

CROP_PARAM=(`mplayers $1 -vf cropdetect | cut -d= -f2 | cut -d\) -f1`)

Since I'm not sure what 'mplayers' is, I'm assuming it's a variant of mplayer. A slight snafu with mplayer is that it spits out oodles of cropping data instead of just one line- the above parameter ends up being an array of crop values. $CROP_PARAM will give you the first one.

lpn1160
12th August 2006, 16:17
Pretty much what I,ve been looking for. Will give a try. Thank You