ffmpeg Basics
A starting point to get the most out of ffmpeg to convert and transcode video formats and image sequences.
Authors: David Hecker
Created: 12 Oct 2024 Last updated: 24 Jun 2025
Purpose
ffmpeg is a command line tool used for performing various actions on video files and images. These include converting files between formats, joining files together, splitting audio tracks out from videos, adjusting keyframe intervals, etc.
Install ffmpeg
Download ffmpeg builds for your operating system from here: https://ffmpeg.org/download.html
Windows 10
Windows instructions: https://www.wikihow.com/Install-FFmpeg-on-Windows
Mac OS X
Alternatively, install using the command line on Mac OS X: Install Homebrew:
Once Homebrew is installed, tell it to install ffmpeg:
To update an existing ffmpeg install:
Basic ffmpeg Commands
Get info about a file
Convert image format, adjust size
Encode to MP4 using h264 video, MP2 audio
Convert to MP4, adjust size, maintaining proportions
Encode folder of items, output retains original filename
Convert to MP4, specify keyframe interval
Export audio only
Add audio silence to an audio file
Both of these methods transcode the file, so formats can be changed if required. Replace 1
in each example with the required duration in seconds.
- Add silence to the start of a file:
- Add silence to the end of a file:
Export video as frames
-r 30
sets the frame rate
Export parts of video as frames
This example will export only the frames between 2-6 seconds and 15-24 seconds
Create thumbnails at set intervals
- Output one image every second:
- Output one image every minute:
Convert image sequence to video
-r
sets the frame rate-s
sets the sizein%04d.png
specifies the filenames and padding-crf
sets the quality (lower is better)
Advanced ffmpeg Commands
Convert a top/bottom alpha-packed MP4 to HAP Alpha
ffmpeg -i in.mp4 -filter_complex "[0:v]pad=width=456:height=4320:x=1:y=0[a];[a]split=2[in1][in2];[in1]crop=in_w:in_h/2:0:0[top];[in2]crop=in_w:in_h/2:0:in_h/2[bottom];[top][bottom]alphamerge" -c:v hap -format hap_alpha -compressor snappy -chunks 4 -an -movflags faststart out.mov
Batch Processing
Multiple files in a folder can be batch processed using the following commands.
macOS/Linux
for file in *.mp4 ; do ffmpeg -i ${file} -crf 16 -c:v libx264 -c:a aac outfolder/basename ${file} .mp416.mp4 ; done
Windows (using PowerShell)
Get-ChildItem *.mp4| ForEach -Process {ffmpeg -i $_ -crf 16 -c:v libx264 -c:a aac ('./Output/'$_.BaseName + '-16' + '.mp4')}
Documentation
Online help: https://ffmpeg.org/ffmpeg.html
Terminal help: ffmpeg -h
GUI Alternatives
ffworks
https://www.ffworks.net/download.html
Handbrake
Only use this if you're really desperate or lazy and you don't need as much manual control over the compression.