Desktop Capture – Images and Video

Desktop Capture – Images and Video

A screen capture, as either an image or video, is a useful way to gather details about a computer program or behavior. These details can be used later as a reference. One common example are videos that provide “how to” instruction with step by step details being replaced with a follow along method.

In this post I’ll be covering how to capture the desktop screen of a computer and creating image or video files. I’ll be using built in functions, FFMPeg, and VirtualBox to demonstrate this ability.

Computers have a [PrtScr] button that captures the entire desktop as an image when pressed. To capture just the active window, press [PrtScr] + [Alt]. This is the most simplest way to save what appears on the screen.

This capture example can be used as a way to capture a screen with a command. The following command used imagemagick to capture the entire screen to an image file.

import -window root ScreenCapture.png

If we use a script to run the capture command at set intervals and save individual files, we can use these to create a video. This is useful to capture desktop activity for auditing purposes. The final video can be substantially smaller that higher frame rate video. This can be useful when monitoring the use of a system.

Creating a native video capture will require software. This command uses FFMpeg to capture a full screen 1920 x 1080 video of the desktop.

ffmpeg -video_size 1920x1080 -framerate 15 -f x11grab -i :0.0+0,0 FullScreenVideoCapture.mp4

The video size is easy to see in the command, as is the framerate. If we wanted to capture just an area of the screen, instead of the entire screen we would need to set the start and end x,y coordinates. Here is the command to capture a region of the desktop.

ffmpeg -video_size 747x460 -framerate 15 -f x11grab -i :0.0+1068,414 RegionVideoCapture.mp4

The starting point is set at 1068×414 and it goes spans out 747×460 from there. The results are similar to the active window capture done earlier. This is a bit intensive, you need to know where on the screen and how big the capture will need to be. You can do this with an initial full screen image capture, then use an image editor to find the x,y coordinates.

FFMpeg is a powerful tool that has key desktop capture features. Advanced desktop capturing, like watermarks, zooming, and pop up dialogs can be replicated in FFMpeg. However, this will require more than our simple one liner commands used so far.

With VMs, screen capturing works basically the same way as it does for physical machines. VirtualBox provides a built in video capture feature. This can be found by opening the properties of the VM and selecting the display settings and clicking the video capture tab. Here you can set where to save the video file, the frame size and rate, as well as the quality of the video file. Enabling this will create a video file when you boot up your VM. Typically you will not choose this option.

It is more likely that the video capture will be done using the VM menu instead. Under view, there is an option to select video capture. This will immediately start to capture the desktop into a video file, which will be located in your VirtualBox VM folder if you have not defined a location. Selecting it again will stop the video capture of the VM. When it is running, the status bar will display a moving reel icon.

Screen capture is a useful tool. It provides a way to gather information on how a system is operating and that information can be referenced later. This post serves as an introduction to the concept of screen capture. There are more details and uses of screen capture available elsewhere. Thank you for joining me as we covered this material. I hope you find screen capture as useful a tool as I have.

Comments are closed.