Home Games How to save the desktop from the terminal with FFmpeg

banneraliexp

How to save the desktop from the terminal with FFmpeg

by ace

FFmpeg is famous for converting audio and video in different formats, and now, you will see how to record the desktop from the terminal with FFmpeg.

FFmpeg is a very powerful tool with which we can perform many tasks related to video and audio, and it also allows us to record our PC screen.

How to save the desktop from the terminal with FFmpeg

Yes. FFmpeg allows us to record our desktop screen. Like other programs, like VLC or SimpleScreenRecorder, FFmpeg allows us to record the desktop screen with and without audio.

In addition, it will also allow us to record only a part of our desktop, something that unfortunately would be easier using an application with a user interface that would allow us to select the region to be recorded with the pointer.

So, below, how to make a recording of your desktop, without leaving the terminal.

How to save the desktop from the terminal with FFmpeg

To begin the procedure, you first need to have FFmpeg installed on your system. If not, use one of the tutorials below to install the application:
How to install the FFmpeg multimedia framework on Linux via Snap
How to install the latest version of FFmpeg on Linux Debian, Ubuntu and Fedora
How to encode H.265 video using FFmpeg on Linux (4K and 8K)

Then, to save the desktop from the terminal with FFmpeg, open a terminal and run the following command:

ffmpeg -video_size 1920×1080 -framerate 25 -f x11grab -i: 0.0 saida.mp4

Explaining the above command:
1920 × 1080 is the resolution used for recording.
Framerate is the number of frames per minute.
0.0 is the region to record. You can provide a starting point X and Y to record a part of the screen after the sum symbol, which can be left as 0.0 + 100,200 for a window that starts at point X = 100 and point Y = 200.
saida.mp4 is the output file.

As it was executed above, the file will be saved in the user’s personal folder with the name “saida.mp4”.

Finally, to stop recording, just press the Ctrl + C keys.

If you want to record the audio too, the commands would look like this:
For Pulse Audio:

ffmpeg -video_size 1920×1080 -framerate 25 -f x11grab -i: 0.0 -f pulse -ac 2 -i default saida.mkv

For ALSA:

ffmpeg -video_size 1920×1080 -framerate 25 -f x11grab -i: 0.0 -f alsa -ac 2 -i hw: 0 saida.mkv

To improve sound quality, it is best to close all programs that are not needed.

In both cases, to stop recording, press Ctrl + C. When doing this, the video will be saved in your personal folder with the name used in the command, in these cases “saida.mp4” or “saida.mkv”.

The size of the video must be taken into account. In the commands, “1920 × 1080” was placed, but it is better that you add your own preferred size / resolution there.

Please note that it is not worth making a script to execute in an order or sequence, as one of the commands can fail or, at best, complicate our lives at the moment we would like to stop recording.

What’s *

* …

bannerebay

Related Articles

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More