Recording screencasts and post-processing them for publishing on sites like YouTube or as HTML5 videos was a tedious and error-prone task for me up until some months ago: Recording software like recordMyDesktop, istanbul or xvidcap didn’t produce good results, if working at all. Video editors like avidemux, cinelerra, kdenlive or kino were lacking important features, had a cumbersome user interface or crashed in the twinkling of an eye.
Fortunately things changed when I discovered that ffmpeg works great for taking raw screencasts and when kdenlive 0.8.2 was released. Kdenlive had always been a promising application: A solid set of features, more than I probably ever need, arranged in a convenient user interface. Yet I was never able to accomplish even the simplest task with it in earlier versions — it almost certainly crashed somewhere in between. This behavior has changed significantly in recent versions – I’ve produced a bunch of videos with it now without a single crash. And from what you can read in the web, this seems to be a common observation. Good work, kdenlive developers!
In the remainder I’ll describe my workflow for producing screencasts for upload to YouTube. It can easily be adjusted for other sites like blip.tv, vimeo or HTML5 videos.
Please install ffmpeg – any version should be fine and your distribution surely has packages for it. Also install kdenlive, but take care to get version 0.8.2.1 or later. It’s available in Ubuntu 12.04 Precise (universe) or Debian testing for example.
Recording Raw Screencasts
I’ll assume you’re going to record a screencast of a specific application window. Usually you’re able to resize that and it makes much sense to optimize its size for the end presentation. Best results for YouTube are achieved with an aspect ratio of 16:9. Corresponding video sizes are shown in the following table (second column):
|1080p (Full HD)||1920×1080||1440×1080||8000 kbps|
|720p (HD)||1280×720||960×720||5000 kbps|
Now change the size of the window to record to your favorite size from the table above. One good way to achieve that is to use KWin (right-click on the window title, Advanced, Special Window Settings, Size & Position). You also need to know/change the position of the window. Again, KWin comes in handy:
Remember (or note down) the values and apply the settings. Afterwards it’s time to start recording the screencast.
ffmpeg -f x11grab -show_region 1 -y -r 25 -s 1280x720 -i :0.0+100,200 -vcodec ffv1 screencast.avi
Let’s review all the parameters briefly.
|Enables screen recording.|
|Indicates the recording region on the screen. The indicator itself is not recorded.|
|The video screencast.avi will be overwritten, if it exists.|
|The video is recorded with a framerate of 25 (frames per second).|
|The size of the video. It should correspond to the size you set via kwin above, and ideally also corresponds to one of the YouTube formats in the table above.|
|100,200 is the x,y position of the top left corner of the region to record. This should correspond to the position you set via kwin above. :0.0 tells ffmpeg which display and which screen to record. Normally you can leave it as :0.0.|
|A losless, ffmpeg-builtin video codec is used.|
Change the parameters as needed (you probably have to change 1280×720 and 100,200 and can leave the rest as is) and start ffmpeg. It will start recording the screencast immediately. To stop recording, hit Ctrl+C in the shell where ffmpeg is running. The raw screencast will be called screencast.avi and can be viewed with e.g. mplayer.
Possibly you have to repeat this step several times to find optimal settings. If the video stutters, record to a faster drive, use a smaller video size or lower the framerate. Don’t use a framerate lower than 25 though. If the video stutters because your hard drive is too slow and you don’t have a faster one, you can also try to use a different codec than ffv1. Try
ffmpeg -f x11grab -show_region 1 -y -r 25 -s 1280x720 -i :0.0+100,200 -b 8000000 screencast.webm
Post-processing for Publishing
A huge topic on its own, so I don’t really want to start writing much here, but just leave a couple of recommendations:
- If you recorded to .webm above, you can upload the video directly to YouTube
- If you recorded to .avi with ffv1 codec or if you want to add some background music, effects, title clip etc, I strongly recommend giving kdenlive a try.
- If you recorded to .avi with ffv1 codec and don’t want to use kdenlive for some reason, you can convert it using ffmpeg on the command line:
ffmpeg -i screencast.avi -b 8000000 screencast.webm
The value for -b should correspond to the bitrate in the table above, here 8000000 = 8000 kbps. Now upload screencast.webm.
- If you’re looking for some background music, jamendo.com is worth a try.
Wondering why this appears on planet KDE? The answer is simple: I want to see more screencasts here! (GSoC/SoK students, I’m looking at you!)