
$ ffmpeg -f x11grab -video_size 1920x1080 -framerate 25 -i $DISPLAY -f alsa -i default -c:v libx264 -preset ultrafast -c:a aac screen.mp4 To take a screencast screen.mp4 with lossy encoding and with audio: Here, the Huffyuv codec is used, which is fast, but produces huge file sizes. $ ffmpeg -f x11grab -video_size 1920x1080 -framerate 25 -i $DISPLAY -c:v ffvhuff screen.mkv To take a screencast screen.mkv with lossless encoding and without audio: Where -video_size specifies the size of the area to capture. $ ffmpeg -f x11grab -video_size 1920x1080 -i $DISPLAY -vframes 1 screen.png See FFmpeg encoding wiki and ffmpeg(1) § EXAMPLES.įFmpeg includes the x11grab and ALSA virtual devices that enable capturing the entire user display and audio input. However you may want to force the number of threads available by the parameter -threads number.

FFmpeg should automatically choose the number of CPU threads available.Failing to do so may cause parameters being skipped or will prevent FFmpeg from executing. It is important that parameters are specified in the correct order (e.g.See FFmpeg Wiki: H.264 and FFmpeg Wiki: AAC for more info. This allows the video to begin playing faster if it is watched via progressive download playback. -movflags +faststart is an option for MP4 output that move some data to the beginning of the file after encoding is finished.



-crf 20 selects a CRF value of 20 which will result in a high quality output.Use the slowest preset that you have patience for. -preset slow selects the slow x264 encoding preset.-c:v libx264 selects the video encoder libx264, which is a H.264 encoder.Add -c:a aac: ffmpeg -i input.avi -c:v libx264 -preset slow -crf 20 -c:a aac -b:a 160k -vf format=yuv420p -movflags +faststart output.mp4
