User Tools

Site Tools


Category5 Technology TV broadcasts a live show each week, and after each show, I have to convert a lot of junk. A long time ago, I created a dirty little script to do most of the work for me. A number of weeks ago, [ The Ubuntu Podcast] mentioned this on their show (thanks for the props, guys!), wondering if they could get a copy of my handy-dandy script to save themselves some time and headache each week.

So, I cleaned up the code (as it was never actually intended for distribution) and here it is. Hope you enjoy.

Please feel free to post improvements if you have any, which can benefit anyone who decides to use this.

What You Get

When you apply your video file to this script, you'll get: * an OGV version * an MP3 audio-only version * screengrab thumbnails in 640, 320 and 200 width JPG images * a packaged ZIP file with all the thumbnails from the video

I'm always willing to make additions or improvements, so feel free to post suggestions and/or requests.

Known Issues

* With some source files, OGG video files are playing back too fast.

Current Official Version


Operating Platform

* Linux


* a computer running Linux * minimum 2 core system for reasonable performance * ffmpeg * ffmpeg2theora * imagemagick

The Script
# set the source extension (eg. avi, flv, mp4, etc)
echo Video file converter script based on Category5.TV\'s method.
echo Slapped together by Robbie Ferguson for the guys over at
echo Version 1.2
echo Please note: this is an extremely CPU-intensive script.
echo              Not recommended for anything less than a dual-core system.
echo To install:  sudo apt-get install ffmpeg ffmpeg2theora imagemagick
echo To run:  $0 filename
echo          Don\'t specify extension\; must match SOURCETYPE \(currently $SOURCETYPE\)
echo          You can change this by editing $0
if [ -z "$1" ]; then
exit 1;
# make mp3
# because we love to appease the masses
  echo Creating MP3 file from $1.$SOURCETYPE
	ffmpeg -acodec mp3 -vn -ab 112k -i $1.$SOURCETYPE $1.mp3 &
# make ogv
# because we love to support open source!
	# Specify the source bitrate here
	# (if playback seems fast or slow, set value to match source video)
	# specify video quality 1-10
	# specify video bitrate 1-16778
	# specify audio quality -2-10
	# specify audio bitrate
	# choose deinterlacer (lb, li, ci, md, fd) - see 'ffmpeg2 --pp help' for details
	echo Creating OGV file from $1.$SOURCETYPE
	ffmpeg2theora -F $FPS -v $VIDQUALITY --optimize -V $VIDBITRATE --pp $DEINTERLACER --deinterlace -a $AUDQUALITY -A $AUDBITRATE -o $1.ogv $1.$SOURCETYPE &
# make screenshots
# First, extract 1fps to PNG files.  Then save those into an accelerated video file.  Then, extract images at 1fps from the accelerated file.
# There might be a better way to do this, but it is pretty zippy, and gets the job done.
# This results in approximately 150 pictures of a one-hour video.
# I output in 640, 320 and 200 widths.  The 200 is what we use for web site thumbs, 320 is for RSS, and 640 is for archive.
	echo Creating screen grabs from $1.$SOURCETYPE
	mkdir $1_640
	ffmpeg -i $1.$SOURCETYPE -s 640x480 -r 1 -f image2 $1_640/%05d.png
	ffmpeg -i $1_640/%05d.png -b 512 -qscale .1 $1_640/$1_accel.avi
	rm $1_640/*.png
	ffmpeg -i $1_640/$1_accel.avi -an -r 1 -y $1_640/$1_%d.jpg
	rm $1_640/$1_accel.avi
	mkdir $1_320
	mkdir $1_200
	cp $1_640/* $1_320/
	cp $1_640/* $1_200/
	mogrify -resize 320 $1_320/*.jpg
	mogrify -resize 200 $1_200/*.jpg
# create a distributable zip archive of the thumbnail images
# because we like to share...
	zip thumbs_$ $1_640/* $1_320/* $1_200/*

1.2 - Added dynamic script name to usage instructions. Very minor.

1.1 - Added FPS override to fix framerate issues when video framerate is not detected correctly. Make sure you set FPS to match the source video if OGV playback seems fast or slow.

1.0 - Cleaned up my code and created this redistributable version of my conversion script at the request of

scripts/cat5convert.txt · Last modified: 2012/01/26 09:18 by import