I’ve been experimenting with mencoder to convert my AVI movies into a format that I can download onto my cellphone and finally found a site where they explain the various parameters needed for the mencoder program to get it to work. Problem is, they’re a pain to type in each time. How do I turn an ugly command line invocation into a nice shell script?
Through an eerie coincidence, I too have been going through that same task, converting movies to dump onto my new Blackberry Pearl, which actually does quite a good job with video, rather to my surprise! It’s not much bigger than a postage stamp, but it’s watchable, and heck, it’s a cellphone… 🙂
Anyway, the information I found on using mencoder is from the8thsign.com. If you’re on a PC, then you might find this posting in Pinstack.com’s Blackberry forums useful.
The command I used is:
lavc -oac lavc -lavcopts vcodec=mpeg4:vbitrate=230:acodec=mp3:abitrate=64
Scary, isn’t it? No wonder you’re looking for a way to avoid typing that in each time you want to convert a movie!
Fortunately, it’s a very regular pattern and that means that it’s not hard to replace “input” and “output” with specific variables and just prompt for those values when the script is started. That’s exactly what the following script does:
# This script converts regular AVI into the format needed for the
# Blackberry Pearl …
mencoder=/Users/taylor/bin/mencoder
echo -n “input file: “
read input
echo -n “output file: “
read output
echo “Converting $input to $output…”
$mencoder -vf scale=240:135 “$input” -o “$output” -of avi -ofps 15 -ovc \
lavc -oac lavc -lavcopts vcodec=mpeg4:vbitrate=230:acodec=mp3:abitrate=64
exit 0
Save this as, say, “convert-movies”, make it an executable with the command chmod +x convert-movies, and now you can just type “convert-movies” to get the script running:
input file: ../Movies/Bourne-Identity.avi
output file: ~/Desktop/bourne-identity.avi
Converting ../Movies/Bourne-Identity.avi to ~/Desktop/bourne-identity.avi…
MEncoder dev-CVS-051126-18:35-3.3 (C) 2000-2005 MPlayer Team
Mac OSX static build for ffmpegX
AltiVec found
CPU: PowerPC
. . .
Nice, simple, and far easier to remember. Note that I already knew the name of the input file, so you can’t use filename completion as you could on the command line (in fact, it would be pretty easy to add the ability to specify the input and/or output filenames on the command line itself, allowing you to type in “convert-movie bourne-identity.avi bourne-identity-out.avi” or similar. I’ll leave that as an exercise for you, dear reader, however!)
hello dave
we all very thankfull to you to update us in such usefully ways
with regard
chetan
Hi,
alternatively tou can use mencoder.conf file. It is a file where you can store your options and what is nice about it is that you can set some profiles there. This file should be found in ~/.mplayer/mencoder.conf if it’s not you can create it.
So your file could look like this :
[bb] # name of the profile
vf=scale=240:135
of=avi
ofps=15
ovc=lavc=1
oac=lavc=1
lavcopts=vcodec=mpeg4:vbitrate=230:acodec=mp3:abitrate=64
You can also set default output filename:
o=output.avi
You can have many profiles like one above, you can set default settings using [default] profile.
To use a profile run mencoder like this:
mencoder -profile bb -o
You could make an alias of it or wrap a little script around it, which would for example save output file with the same name as input file but with ex. .avi.new extension.
So it would take only to type:
yourscriptname
to convert your file. And ‘yourscriptname’ can be shorter of course 🙂
With a script like that you can even make some batch conversion:
for i in *.avi ; do yourscriptname $i ; done
Those are just examples and you should tweak them to fit your needs
jot