====== Screen Capture ====== Whether you need to capture what's happening on your screen for a performance, a tutorial, or for live broadcast, there are several ways to record the Linux screen. ===== FFmpeg ===== [[http://ffmpeg.org|Ffmpeg]] is a versatile video engine. You should have installed it when setting up Slackermedia; if not, read the section on how to do a proper Slackermedia [[ffmpeginstall|FFmpeg Install]], and the basic overview of its usage in the [[ffmpeg]] section. Ffmpeg should have had [[kernel|setcap]] permission granted to it so that its attempt to capture activity in realtime is not squelched by the kernel. Just as ffmpeg can capture input from webcams or existing movie streams, it can also capture the video display of your computer: $ ffmpeg -f x11grab -an -s hd1080 -r 25 \ -v:b 23000 -i :0.0 -g 1 -q:v 0.1 \ -vcodec libxvid screenCapture1.mp4 This translates to: * ''-f x11grab'' sets the input format to x11grab, in absence of a video stream of a more traditional format * ''-an'' means it will not capture audio * ''-s hd1080'' captures HD video (1920x1080) * ''-r 25'' sets frame rate to 25 * ''-v:b 23000'' sets the video bitrate to 23Mbps * ''-i :0.0'' points the input the first monitor of your computer * ''-g 1'' sets the group of pictures to 1, a very high setting, resulting in a large file * ''-q:v 0.1'' sets compression quality to very high * ''-vcodec'' sets the video codec for output to use libxvid, a good open source codec * ''screenCapture1.mp4'' sets the filename of the ouput file The resulting file is a large, unwieldy video of whatever was happening on the screen from the start of the command up until it is terminated with ''ctrl'' ''c''. Probably, you will need to compress the video later, but this can be done with either [[ffmpeg2theora]] or [[ffmpeg]]. To capture the screen plus audio, you must know what audio device you want to record. This can often be a frustrating process, and is best done [[linuxaudio|as a separate exercise]]. That is, figure out your audio setup, determine what device that the computer sees maps to which peripheral you have connected to the physical box, and then go about recording the screen with audio armed with your knew understanding of how your computer names its audio devices. Once you are ready, a command like this should do nicely: ffmpeg -f alsa -i hw:2 -f x11grab -s hd1080 \ -r 25 -v:b 21000 -i :0.0 -g 1 -q:v 0.1 \ -vcodec libxvid output.mp4 It's basically the same command as above, but this time one of the input formats is set to ''alsa'' and an input device is set to ''hw:2'', which maps in the physical world (in this real-life example) to an external USB microphone headset. The result is a large file with both video and audio. ==== FFmpeg & Mplayer ==== User ''rowinggolfer'' and Linux blog [[http://linuxbookpro.com]] devised a hybrid method of not only capturing the screen, but also super-imposing and in-setting video from a webcam to achieve a live picture-in-picture mode. First, start Mplayer to capture input from your webcam in a relatively small window to achieve the picture-in-picture look: $ mplayer tv:// -tv driver=v4l2:width=320:height=240:device=/dev/video0 -vo xv -noborder -geometry 100%:100% -ontop When that window appears, ''alt''-click on it and drag it to where you want it on your screen. If you would rather have a border on the window, omit the ''-noborder'' switch from the command. Position the screen and then right-click on the window's title bar and hide the border. In a separate terminal, start ffmpeg: $ ffmpeg -f oss -i /dev/dsp -f x11grab -s hd1080 -r 25 -i :0.0 out.mp4 Record your screencast. ===== RecordMyDesktop ===== There are two versions of RecordMyDesktop; the terminal command ''recordmydesktop'' and the GUI frontend, **qt-recordmydeskteop**. The latter is just a frontend to the first, so the basic functionality is exactly the same. ==== Install ==== Install the terminal command and, optionally, the frontend from [[http://slackbuilds.org]]. If you have already installed [[kdenlive]] then you may already have these installed, as they are soft-dependencies for that. ==== Usage ==== Start ''recordmydesktop'' from the terminal, or ''qt-recordmydesktop'' from the **K Menu**. Recordmydesktop has the ability to use either ALSA or JACK as its audio input, meaning that it's a great choice if you're capturing a musical performance or tutorial. [{{ qtrecordmydesktop.jpg?666 | The qt-recordmydesktop interface. }}] Two things to keep in mind: * If you want your video to sync up with sound, use either **24** or **25** frames per second. * Generally, ''compress on the fly'' is a bad option to use, so avoid that unless your computer is very powerful, or you simply haven't got the harddrive space for a full-quality video to be saved onto it even temporarily. By default, the whole screen is recorded. If you don't need or want the whole screen to be recorded, you can set a specific area. Click the **Select Window** button in the **qt-recordmydesktop** control panel. Click and drag on the preview window to set the "hot" area. [{{ qtrecordmywindow.jpg | Capture a portion of your screen. }}] After capture, ''recordmydesktop'' will compress your video for you, and it usually does a good job of it. If you're unhappy with the results, you can try your hand at compressing the source video yourself using [[ffmpeg2theora]] or [[ffmpeg]]. **See Also** \\ [[ffmpeg|Ffmpeg]] \\ [[obs|Open Broadcast Studio (OBS)]] [[samplv1|R]] [[start|S]] [[screenwriter|Q]]