FFmpeg is one of my favorite tools, though it can be quite challenging to master. This page is dedicated to sharing the commands and knowledge I’ve accumulated from using FFmpeg.
Check back soon for more updates!
Encoding Videos
Here’s a simple reference for re-encoding videos.
WEBM
For WEBM files, there are three common codecs: VP8, VP9, and AV11.
VP8
ffmpeg -i video.mkv -c:v libvpx -c:a libvorbis video.webm
VP9
ffmpeg -i video.mkv -c:v libvpx-vp9 -c:a libopus video.webm
AV1
ffmpeg -i video.mkv -c:v libsvtav1 -c:a libopus video.webm
MP4
For MP4 files, you can use the following codecs:
H.264 (x264)
ffmpeg -i video.mkv -c:v libx264 -c:a aac video.mp4
H.265 (x265)
ffmpeg -i video.mkv -c:v libx265 -c:a aac video.mp4
NVIDIA NVENC H.264
If you have an NVIDIA GPU, you can use the NVENC encoder for H.264:
ffmpeg -i video.mkv -c:v h264_nvenc -c:a aac video.mp4
NVIDIA NVENC H.265
For H.265 using NVIDIA NVENC:
ffmpeg -i video.mkv -c:v hevc_nvenc -c:a aac video.mp4
Recording Screen
To record your screen, use the following command:
ffmpeg -y -f x11grab -s 1920x1080 -i :0.0 test.mkv
You can also add -framerate 30
to set a custom frame rate.
Recording Microphone
To record audio from your microphone:
ffmpeg -f alsa -i default -c:a flac test.flac
Recording Screen and Microphone
To record both your screen and microphone:
ffmpeg -y -f x11grab -s 1920x1080 -i :0.0 -f alsa -i default test.mkv
With specific codecs:
ffmpeg -y -f x11grab -s 1920x1080 -i :0.0 -f alsa -i default -c:a flac -c:v libx264 test.mkv
-
The FFmpeg codecs are: VP8 =
libvpx
, VP9 =libvpx-vp9
, AV1 =libsvtav1
. ↩︎