<- Back
ffmpeg
Record screencasts (lossless)
4K
ffmpeg -video_size 3840x2160 -framerate 30 -f x11grab -i :0.0 -c:v libx264rgb -qp 0 -preset ultrafast capture.mp4
Downscaled to 1920x1080
ffmpeg -video_size 3840x2160 -framerate 30 -f x11grab -i :0.0 -vf scale=1920:1080 -c:v libx264rgb -qp 0 -preset ultrafast capture.mp4
With audio you hear, but without microphone (use 'pacmd list-sources')
ffmpeg -f pulse -i alsa_output.pci-0000_00_1f.3.analog-stereo.monitor -video_size 3840x2160 -framerate 30 -f x11grab -i :0.0 -c:v libx264rgb -qp 0 -preset ultrafast capture.mp4
With both, speakers and microphone audio
ffmpeg -f pulse -ac 2 -i alsa_output.pci-0000_00_1f.3.analog-stereo.monitor -f pulse -ac 1 -i alsa_input.pci-0000_00_1f.3.analog-stereo -filter_complex amix=inputs=2 -video_size 3840x2160 -framerate 30 -f x11grab -i :0.0 -c:v libx264rgb -qp 0 -preset ultrafast capture.mp4
Convert
For WhatsApp
ffmpeg -i input.mp4 -c:v libx264 -profile:v baseline -level 3.0 -pix_fmt yuv420p -preset slow -crf 22 output.mp4
AV1
ffmpeg -i input.mp4 -c:v libaom-av1 -c:a libopus -b:a 96k output.webm
Keep metadata
ffmpeg -i input.mp4 -movflags use_metadata_tags -map_metadata 0
Cut video
Start timestamp and duration
ffmpeg -ss 00:00:30.0 -i input.mp4 -c copy -t 00:00:44.0 output.mp4
Resize/scale video
Resize to 1280 pixels width
ffmpeg -i input.mp4 -vf scale=1280:-4 output.mp4
Batch resize whole folder
find . -type f -iname '*.mp4' -printf '%P\n' | xargs --max-args=1 sh -c 'ffmpeg -i "${0}" -vf scale=1280:-4 "${0%.*}_.mp4"'
Increase volume
Detect max_volume
ffmpeg -i input.mp4 -af "volumedetect" -vn -sn -dn -f null /dev/null
Increase volume
ffmpeg -i input.mp4 -af "volume=5dB" -c:v copy -c:a aac -b:a 96k output.mp4
Reduce audio noise
Reduce noise
ffmpeg -i input.mp4 -af "highpass=f=200, lowpass=f=2500, volume=45dB, afftdn=nf=-25" -c:v copy -c:a aac -b:a 96k output.mp4
Capture webcam frame
Reduce noise
ffmpeg -f video4linux2 -s 640x480 -i /dev/video0 -ss 0:0:2 -frames 1 /tmp/out.jpg
Audio
Extract audio stream (use ffprobe before)
ffmpeg -i input.mp4 -vn -acodec copy output.aac
Drop audio stream
ffmpeg -i input.mp4 -an output.mp4
Speed
Speed up video
ffmpeg -i input.mp4 -filter:v "setpts=PTS/20" output.mp4
Subtitles
Embed subtitles
ffmpeg -i input.mp4 -i english.vtt -c copy -c:s mov_text -metadata:s:s:0 language=eng output.mp4
Embed subtitles (multiple languages)
ffmpeg -i input.mp4 -i english.vtt -i german.vtt -map 0 -map 1:s -map 2:s -c copy -c:s mov_text -c:s mov_text -metadata:s:s:0 language=eng -metadata:s:s:1 language=ger output.mp4