www.technotes.se » Blog Archive » Recording your Linux desktop with ffmpeg
Oct
24
Posted on 24-10-2010
Filed Under (Desktop recording, Linux, ffmpeg) by Christian

Presenting a video recording of your desktop can be a very helpful tool in tutorials such as this one. This tutorial is written for Debian but the general approach is applicable to most Linux distributions.

Recording your Linux desktop with ffmpeg using Debian

We need to add the Debian multimedia repositories for the video codecs:

Download the Debian multimedia keyring package:

$ wget http://www.debian-multimedia.org/pool/main/d/debian-multimedia-keyring/debian-multimedia-keyring_2008.10.16_all.deb

Become root:

$ su root

Install the keyring package:

$ dpkg -i debian-multimedia-keyring_2008.10.16_all.deb

Find your Debian variant and add the repositories to your /etc/apt/sources.list file.

$ gedit /etc/apt/sources.list
Editing /etc/apt/sources.list

Editing /etc/apt/sources.list

Example: For sid (unstable)

deb http://ftp.se.debian.org/debian/ unstable main
deb-src http://ftp.se.debian.org/debian/ unstable main

deb http://ftp.de.debian.org/debian/ unstable main contrib non-free
deb-src http://ftp.de.debian.org/debian/ unstable main contrib non-free

# For mulitmedia codecs such as aac etc. for ffmpeg
deb ftp://ftp.debian-multimedia.org sid main non-free

Save and close gedir.

Refresh your apt sources:

$ apt-get update

Compiling ffmpeg with the corect video codecs turned on.

Follow the tutorial by “FakeOutdoorsman” HOWTO: Install and use the latest FFmpeg and x264 including steps 1-5 UPDATE: You can skip step 4. “Install libvpx (optional)”.

To record your desktop screen:

$ ffmpeg -r 30 -s 1280x720 -f x11grab -i :0.0 -vcodec msmpeg4v2 -qscale 1 filename.avi

Explanation of: “$ ffmpeg -r 30 -s 1280×720 -f x11grab -i :0.0 -vcodec msmpeg4v2 -qscale 1 filename.avi”

$ ffmpeg -r 30 -s 1280×720 -f x11grab -i :0.0 -vcodec msmpeg4v2 -qscale 1 filename.avi
The frame rate in which you want to record, in this example 30 frames per seconds is used.

$ ffmpeg -r 30 -s 1280×720 -f x11grab -i :0.0 -vcodec msmpeg4v2 -qscale 1 filename.avi
The screen resolution that you want to record in (typically your desktop screen resolution). Note: do not try to use a larger screen size than your desktop screen size.

$ ffmpeg -r 30 -s 1280×720 -f x11grab -i :0.0 -vcodec msmpeg4v2 -qscale 1 filename.avi
This flag is used to tell ffmpeg to record the x11 window.

$ ffmpeg -r 30 -s 1280×720 -f x11grab -i :0.0 -vcodec msmpeg4v2 -qscale 1 filename.avi
Here the special input file is a x11 screen buffer. In this case we record the default window 0 but you can also record another active x11 server window like -i :1.0. Keep in mind that unless the x11 server window is active the screen will be black. You can toggle from :0 (the default x11 server window) to :1 by pressing <crtl><alt>F8. You can toggle black to :0 by pressing <crtl><alt>F7.

$ ffmpeg -r 30 -s 1280×720 -f x11grab -i :0.0 -vcodec msmpeg4v2 -qscale 1 filename.avi
Use the “Microsoft MPEG4-v2″ codec when encoding your video file.
This sets the quality of the file to highest (1). If you increase this value the size of the output file will shrink but the quality of the video will suffer.

$ ffmpeg -r 30 -s 1280×720 -f x11grab -i :0.0 -vcodec msmpeg4v2 -qscale 1 filename.avi
The file name for the output file.

Presenting a video recording of your desktop can be a very helpful tool in tutorials such as this one. The last section if this tutorial will show how you can follow this tutorial and thereby creating your own tutorials. This tutorial is written for Ubuntu but the general approach is applicable to most Linux distrobutions.

[Note] This method uses real-time encoding of the video at a high resolution which can be CPU demanding. You can try to lower the quality by setting -qscale to 2 instead of 1.

(0) Comments    Read More   
Post a Comment
Name:
Email:
Website:
Comments:
*