How to easily take a screenshot from the commandline with ffmpeg

// = How to easily take a screenshot from the commandline with ffmpeg :id: 7efa3b1e-cf5a-4fc1-bba3-be373495118d :author: Andrei Clinciu :website: https://andreiclinciu.net/ :publish_at: 2017-04-13 21:26:00Z :heading_image: /images/blog//old_uploads/FFmpeg_Logo_new.svg_-825x343.png :description: \N :type: article :tags: :keywords: :toc: left :imagesdir: ../assets/

image::{heading_image}[] In this post I intend to show how easy it is to take a screenshot from the CommandLine.

Why would you want to do that? + Well there are times when you simply want to take a screenshot of the screen at certain times to track your activity. Or to make a simple screencast without having to install additional tools.

FFMPEG can be downloaded and installed from the following website: https://www.ffmpeg.org/

For Linux you can also install it via the commandline

To install libav:

…. apt-get install libav-tools ….

To install ffmpeg:

…. apt-get install ffmpeg ….

== To take a screenshot on Linux just type the following in your terminal

[source,lang:sh,decode:true]

ffmpeg -f gdigrab -i desktop -vframes 1 screenshot.jpeg

=== Take a screenshot on  Windows

[source,lang:sh,decode:true]

ffmpeg -f x11grab -video_size $(xdpyinfo | grep dimensions | cut -d" " -f7) -i $DISPLAY -vframes 1 screenshot.jpg

 

Subscribe to my Newsletter

Receive emails about Linux, Programming, Automation, Life tips & Tricks and information about projects I'm working on