Published on

Linux Screen Capture for YouTube

Authors

ffmpeg is the command line utility I chose - does enough, but not too much (like mplayer, for instance).

YouTube and Google ideal input video

  • 640x480 @ 30 fps MPEG4

Preparation

Grab the ffmpeg package from ATrpms.

# rpm --import http://ATrpms.net/RPM-GPG-KEY.atrpms
# scite /etc/yum.repos.d/atrpms.repo
# yum install ffmpeg

For speed of capture :

# Mount a RAM disk (as su) :
mkdir /media/ffmpeg
mount -t tmpfs tmpfs /media/ffmpeg
exit

Capture

Grabbing the screen (the data rate of 1Mb/sec set with '-b' option)

# Grab a standard 640x480 screen from top-left of screen (choose frame rate with '-r')
ffmpeg -f x11grab -r 15 -s 640x480 -i :0.0+5,20 -b 1M /media/ffmpeg/grab.flv

Test the grab - to make sure it's what's needed :

ffplay /media/ffmpeg/grab.flv

In order to play around with different scenes, or intro and lead-out title frames :

# Convert frames to mpeg (can be concatenated easily, output framerate set with '-r')
ffmpeg -i /media/ffmpeg/grab.flv -r 30 /media/ffmpeg/grab.mpg

Making a Title Sequence

# Create title.png from title.svg (inkscape - number of frames=100, at 30fps)
ffmpeg -loop_input -vframes 100 -i title.png -r 30 title.mpg

Join the Scenes together...

# mpg files can be simply 'cat'd together
cat title.mpg frames.mpg > joined.mpg

Test the movie (and/or upload to youtube) :

ffplay joined.mpg

Alternative - build the movie out of frames...

Create frames for movie via drawstuff... Cntrl-W : this is a feature of the drawstuff GUI front-end for ODE - it creates a sequence of .ppm files from the frames of the simulation.

Join the grabbed frames together into a movie :

cd frames
ffmpeg -r 5 -i frame%04d.ppm -r 30 frames.mpg

and then proceed with the cobbling together as before.