Tip Cache
Your source for tech tips
Tip: Encode a video into XVid format
Posted By: apeiro
Cameras and other digital devices can often capture video, but they don't use a space-friendly format. This script uses open source tools to encode an AVI into XVid and MP3.
All you need is a few open source tools:
- transcode
- mjpegtools
- lame
Here's a Bash script that does the trick. Tested on Linux.
#!/bin/sh
if [ "$1" = "" ]; then
echo "usage: encvid <file.avi>"
exit
fi
vidfn=$1
lav2wav -I $vidfn >tmp.$vidfn.wav || exit 1
transcode -i $vidfn -w 512 -y xvid4,null -o tmp.$vidfn.avi || exit 1
lame tmp.$vidfn.wav tmp.$vidfn.mp3 || exit 1
avimerge -i tmp.$vidfn.avi -p tmp.$vidfn.mp3 -o $vidfn.avi || exit 1
rm -f tmp.$vidfn.wav tmp.$vidfn.mp3 tmp.$vidfn.avi
echo "Done."
