Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision |
wiki:screencasttutorial [2011/12/06 04:57] – old revision restored rgareus | wiki:screencasttutorial [2011/12/15 14:38] – 151.29.137.72 |
---|
Not satisfied with the quality of the screencasts made with [[http://recordmydesktop.sourceforge.net/about.php|recordMyDesktop]] I started looking for an alternative that might yield better results, especially the video part. The JACK support of recordMyDesktop is a big plus and quite solid too but recordMyDesktop converts all video to Theora only and this has proved inconvenient when uploaded to a webservice like YouTube. The video quality just degraded too much.\\ | Not satisfied with the quality of the screencasts made with [[http://recordmydesktop.sourceforge.net/about.php|recordMyDesktop]] I started looking for an alternative that might yield better results, especially the video part. The JACK support of recordMyDesktop is a big plus and quite solid too but recordMyDesktop converts all video to Theora only and this has proved inconvenient when uploaded to a webservice like YouTube. The video quality just degraded too much.\\ |
So I needed a different toolset. For the video part I chose [[http://www.ffmpeg.org/|FFmpeg]] for its unrivaled flexibility and support for input and output formats. FFmpeg also has JACK support but I found the JACK input client to be too xrun prone so for the audio part I chose [[apps:all:jack_capture|jack_capture]], a lightweight, flexible commandline driven recording tool.\\ | So I needed a different toolset. For the video part I chose [[http://www.ffmpeg.org/|FFmpeg]] for its unrivaled flexibility and support for input and output formats. FFmpeg also has JACK support but I found the JACK input client to be too xrun prone so for the audio part I chose [[apps:all:jack_capture|jack_capture]], a lightweight, flexible commandline driven recording tool.\\ |
To prevent webservices like YouTube having to downscale or upscale your videos, which deteriorates the quality of your videos drastically, I run the whole screencast session in a nested X server with the help of [[http://www.freedesktop.org/wiki/Software/Xephyr|Xephyr]]. | To prevent webservices like YouTube having to downscale or upscale your videos, which deteriorates the quality of your videos drastically, you can optionally run the whole screencast session in a nested X server with the help of [[http://www.freedesktop.org/wiki/Software/Xephyr|Xephyr]]. |
| |
===== Requirements ===== | ===== Requirements ===== |
* A recent version of FFmpeg compiled with support for the h.264 protocol | * A recent version of FFmpeg compiled with support for the h.264 protocol |
* [[apps:all:jack_capture|jack_capture]] | * [[apps:all:jack_capture|jack_capture]] |
* Xephyr | * Xephyr [optional] |
* A video editor, I use [[http://www.openshotvideo.com/|OpenShot]] or [[http://www.kdenlive.org/|kdenlive]] myself | * A video editor, I use [[http://www.openshotvideo.com/|OpenShot]] or [[http://www.kdenlive.org/|kdenlive]] myself |
* A screen with a minimal horizontal resolution of 1280 pixels | * A screen with a minimal horizontal resolution of 1280 pixels |
| |
===== Set up the screencast session ===== | |
| ===== Screencast script ===== |
| |
| I use a simple script like this: |
| |
| <code>#!/bin/bash |
| |
| DATE=`date +%Y%m%d` |
| TIME=`date +%Hh%M` |
| |
| # Start screencast |
| xterm -e jack_capture -b 24 $HOME/Screencasts/screencast_audio_$DATE-$TIME.wav & |
| ffmpeg -an -f x11grab -r 30 -s 1280x720 -i 0:0 -vcodec libx264 -vpre lossless_ultrafast -threads 4 $HOME/Screencasts/screencast_video_$DATE-$TIME.mkv |
| |
| killall jack_capture</code> |
| |
| You might need to adjust the number of threads for the ffmpeg -threads parameter to match the number of cores of your CPU. If unsure, set it to 0, ffmpeg should then set the numbers of threads automatically. |
| |
| jack_capture by default captures all the audio that is connected to system:ouput. If you want to be able to manually make connections to jack_capture with jack_connect, qjackctl or whatever, you have to pass it the -mc option (you need at least version 0.9.58 for this) |
| |
| ===== Optional Xephyr script ===== |
| |
Set up a Xephyr nested X server with a resolution of 1280x720 as this resolution yields the best result when uploading the final video to a webservice like YouTube. I use a little script for this: | Set up a Xephyr nested X server with a resolution of 1280x720 as this resolution yields the best result when uploading the final video to a webservice like YouTube. I use a little script for this: |
As you can see I set up a session by calling /etc/X11/Xsession. In Ubuntu >= 9.10 this starts up a new fresh Gnome session and because I use IceWM for my main session in which I run Xephyr this works very well. If you're using Gnome as your DE using /etc/X11/Xsession won't work properly so in that case you will have to resort to a different start-up option. This also holds for distributions that don't use /etc/X11/Xsession. | As you can see I set up a session by calling /etc/X11/Xsession. In Ubuntu >= 9.10 this starts up a new fresh Gnome session and because I use IceWM for my main session in which I run Xephyr this works very well. If you're using Gnome as your DE using /etc/X11/Xsession won't work properly so in that case you will have to resort to a different start-up option. This also holds for distributions that don't use /etc/X11/Xsession. |
| |
Now start your screencast within the nested X server, I use a second script for this: | TODO:other distros |
| |
<code>#!/bin/bash | After you ran this Xephyr script, you should run the above screencast script, taking care of making the following changes to it: |
| |
DATE=`date +%Y%m%d` | * add the line "export DISPLAY=:2.0" after the TIME line. |
TIME=`date +%Hh%M` | * change -i 0:0 ffmpeg option to -i :2. |
export DISPLAY=:2.0 | * add the -display 0:0 option to the xterm line (so it won't appear in your screencast). |
| |
# Start screencast | |
xterm -display :0.0 -e jack_capture -b 24 $HOME/Screencasts/screencast_audio_$DATE-$TIME.wav & | |
ffmpeg -an -f x11grab -r 30 -s 1280x720 -i :2 -vcodec libx264 -vpre lossless_ultrafast -threads 4 $HOME/Screencasts/screencast_video_$DATE-$TIME.mkv | |
| |
killall jack_capture</code> | |
| |
You might need to adjust the number of threads for the ffmpeg -threads parameter to match the number of cores of your CPU. If unsure, set it to 0, ffmpeg should then set the numbers of threads automatically. Within the Xephyr session I also use a [[http://gnome-look.org/content/show.php/Basic?content=126559|plain cursor theme without drop shadow]] because ffmpeg doesn't capture the drop shadow properly. As of [[http://git.ffmpeg.org/?p=ffmpeg;a=commit;h=191a50db964768ca4418bdf00b26159a77879b9c|FFmpeg revision 25690]] this has been fixed. | Within the Xephyr session I also use a [[http://gnome-look.org/content/show.php/Basic?content=126559|plain cursor theme without drop shadow]] because ffmpeg doesn't capture the drop shadow properly. As of [[http://git.ffmpeg.org/?p=ffmpeg;a=commit;h=191a50db964768ca4418bdf00b26159a77879b9c|FFmpeg revision 25690]] this has been fixed. |
| |
===== Editing, rendering and uploading to a webservice ===== | ===== Editing, rendering and uploading to a webservice ===== |