ffmpeg
April 16, 2025
ffmpeg
is for video stuff. The basic principle is to take a video/audio input, and transform it to a video/audio output:
ffmpeg -i <input> <output>
Trimming a Video
A video can be trimmed using the following pattern:
ffmpeg -ss 00:00:40 -to 00:01:16 -i input.mp4 output.mp4
-ss
is the start time of the clip you wish to cut, -to
is the end time of the clip, and -i
is the input video file.
There are more accurate ways to cut video using ffmpeg
, but this works fine for my purposes.
Screen Recording and Webcam
Thanks Luke.
Screen Recording
This records both screens into out.mp4
. Here the input :0.0
just means the screen, because we specified the format x11grab
.
ffmpeg -f x11grab -i :0.0 out.mp4
You may need the -s
tag for the screen size (and this should go before the input -i
).
Webcam
Here the input is
ffmpeg -i /dev/video0 out.mkv
To add audio (from pulseaudio),
ffmpeg -i /dev/video0 -f alsa -i default out.mkv