Introduction: Squeeze a Video.

About: computoman.blogspot.com Bytesize articles instead of a trilogy in one post.

If you could save two terabytes of disk space, this instructable might be for you.  Ever get tired of waiting for video to upload to a video site or wish your videos did not take up so much room. A lot of the little digital cameras save movie files in ".avi" format which can be humongous. I know mine does. I was tired of all the wasted space and time it takes to upload the video, Here us what I did.

Note: FFMPEG is available for all the major platforms. There is also gui front ends for the software if you want to use it locally. That is you can point and click instead of using the command line. Your mileage may vary. Also this is great for runningon a remote server if you do not want to bog down your desktop. Great usage for older computers.

Step 1: What You Need.

Software:
ffmpeg
ffmpeg2theora
($ sudo apt-get install ffmpeg ffmpeg2theora)
http://ffmpeg.org/ffmpeg-doc.html

hardware:
An Avi movie file.
Fastest computer available.
Reasonable disk space for all the files.
Some free time.

Step 2: Part 1 Moving From Avi to Mpeg.

In part one we will move from an avi file to an mpeg (intermediary) file. Since I do most things on a remove server where I do not have access to it's keyboard or monitor, I will use the command line. I will usually make a file of the commands needed and then cut and paste to the command line. Makes things very easy to do. Now use this command to make the first conversion. Warning: it will create a very large file. In this case of over five hundred megabyes. Do not let that alarm you. It is all part of the process.

$ ffmpeg -i h5815.avi -b 100000k -ab 128k -ar 44100 h5815.mpeg

Step 3: Step 2: Moving From Mpeg to Ogg Theora.

In this step we will see a dramatic reduction in the size of the file. Certainly most of the better video sites now support the ogg video format. If they do not, they should eventually. In this case we will go from over five hundred megabytes to under a hundred megabyes so that the resulting file is 1/3 of the original file size. So if you have 3 terabytes of avi files they could possibly compressed into just one - one terabyte drive. Awesome. Note: the program will name your output file for you.

$ ffmpeg2theora h5815.mpeg

Step 4: Finally.

Watch the final ogg theora version of the video and make sure all is ok.
Delete the humongous mpeg file. 
You might want to keep the original avi file until you can make a good backup of the ogv file.
244 gigs to 76 megs. Less than a third of the space.
Done!  

Step 5: A Little Automation for Advanced Users.

Create the following batch file to make things a bit easier.
(sv.sh will squeeze a single named video file)
sv.sh
[code]
clear
echo
echo Squeezing video of $1.avi
echo --------------------------------------------------
echo Going from avi to mpeg.
ffmpeg -i $1.avi -b 100000k -ab 128k -ar 44100 $1.mpeg

echo Avi to mpeg done.
echo Going from mpeg to ogv
ffmpeg2theora $1.mpeg

echo Removing unneded mpeg file to free space.
rm $1.mpeg

echo Done
echo ----------------------------------------------------
echo List ogv file
ls -al $1.ogv
echo ====================================================
[/code]

$ chmod +x sv.sh

To compress a file named p,avi, you would use:

$ ./sv.sh p

You could even automate it further by creating a special directory for the avi files and put the batch file in that same directory. After doing that, create a cron entry so that the files can be converted say late at night while you sleep.

smv.sh
[code]
for f in *.avi
do
clear
echo "Processing $f file..."
# take action on each file. $f store current file name
echo
echo Squeezing video of $f
echo --------------------------------------------------
echo Going from avi to mpeg.
filename=${f%\.*}
echo ${filename}
ffmpeg -i $f -b 100000k -ab 128k -ar 44100 ${filename}.mpeg

echo Avi to mpeg done.
echo
echo Going from mpeg to ogv
ffmpeg2theora ${filename}.mpeg

echo Removing unneeded mpeg and avi file to free space.
rm ${filename}.mpeg
# uncomment the following only if the avi files are duplicates..
# rm $f

echo Done
echo ----------------------------------------------------
echo List ogv file
ls -al ${filename}.ogv

echo appending filename to list of files converted
echo ${filename} >> filesdone
echo ====================================================
done
[/code]

To run /path/to/command five minutes after midnight, every day, enter:
# crontab -e

5 0 * * * /path/to/smv.sh

Note: I would only put a copy of the avi files in the working directory. The avi files could then be deleted so they would not be reconverted the next night. I did not add the deletion command to the batch file for safety reasons.

Step 6: Gui for Ffmpeg.

I think the MSWindows version comes with a gui standard. While researching I found a gui front end for ffmpeg, so it is pretty much a point and click. You can certainly test it.  To install it, use the package manager or:

$ sudo apt-get update
$ sudo apt-get install winff

Winff should show up on the Applications > Sound and Video menu.