FFmpeg is a powerful open-source tool for handling multimedia files. Whether you’re encoding, decoding, converting, or streaming, FFmpeg is widely used for manipulating video and audio.
Getting Started
FFmpeg can be installed on various operating systems:
Windows: Download from the official site. Here
Mac: Use Homebrew:
Brew install ffmpeg
Linux: Install via package managers like APT or YUM:
sudo apt install ffmpeg # Debian-based systems
sudo yum install ffmpeg # Red Hat-based systems
Basic Usage
Convert Video Format
ffmpeg -i input.mp4 output.avi
This converts an MP4 file to an AVI format.
Extract Audio from Video
ffmpeg -i video.mp4 -q:a 0 -map a audio.mp3
This extracts audio from a video file and saves it as an MP3.
Resize a Video
ffmpeg -i input.mp4 -vf “scale=1280:720” output.mp4
This trims the video, keeping content between 10 seconds to 1 minute.
Change Video Codec
ffmpeg -i input.mp4 -c:v libx264 -preset fast -crf 23 output.mp4
This changes the video encoding to H.264, optimizing quality and size.
You can use FFmpeg to capture a screenshot (frame) from a video file at a specific timestamp using the following command:
ffmpeg -i input.mp4 -ss 00:00:10 -vframes 1 output.png
Explanation:
-i input.mp4
: Specifies the input video file.
-ss 00:00:10
: Seeks to 10 seconds into the video.
-vframes 1
: Captures one frame.
output.png
: Saves the screenshot as a PNG image.
Alternative Formats:
If you prefer JPEG:
ffmpeg -i input.mp4 -ss 00:00:10 -vframes 1 output.jpg
This method is efficient because it quickly extracts a frame without processing the entire video.
More Resources
For advanced FFmpeg usage, check out: