This guide covers a variety of FFmpeg commands for common multimedia tasks on Ubuntu.
Install FFmpeg on Ubuntu:
sudo apt update
sudo apt install ffmpeg
Convert a video file to another format:
ffmpeg -i input.mp4 output.avi
Trim or cut a specific portion from a video:
ffmpeg -i input.mp4 -ss 00:01:00 -to 00:02:30 -c copy output.mp4
Resize a video to a specific resolution:
ffmpeg -i input.mp4 -vf scale=640:480 output.mp4
Create a video from a sequence of images:
ffmpeg -framerate 24 -pattern_type glob -i 'images/*.png' -c:v libx264 -pix_fmt yuv420p output.mp4
Record a video stream from a URL:
ffmpeg -i http://example.com/stream.m3u8 -c copy output.mp4
ffmpeg -i http://example.com/stream.m3u8 -rtsp_transport tcp -c copy -t 60 output.mp4
Reduce video quality by setting a specific bitrate:
ffmpeg -i input.mp4 -b:v 1M output.mp4
ffmpeg -i input.mp4 -vf "scale=480:480" -vcodec libx264 -crf 30 output.mp4
Extract images at a specific interval from a video:
ffmpeg -i input.mp4 image-%05d.jpg
ffmpeg -i input.mp4 -vf fps=1/5 image-%03d.jpg
Overlay a video on a black screen:
ffmpeg -i input.mp4 -vf "pad=width=1280:height=720:x=0:y=360" output.mp4
Go back to Ubuntu Guide.
Visit other Developer Guides.