FFmpeg command line tool 101
FFmpeg does have a documentation that does a great job of explaining how it works.
To make things short, the FFmpeg command line program expects the following argument format to perform its actions ffmpeg {1} {2} -i {3} {4} {5}
, where:
- global options
- input file options
- input url
- output file options
- output url
The parts 2, 3, 4 and 5 can be as many as you need. It’s easier to understand this argument format in action:
- # WARNING: this file is around 300MB
- $ wget -O bunny_1080p_60fps.mp4 http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_60fps_normal.mp4
- $ ffmpeg \
- -y \ # global options
- -c:a libfdk_aac -c:v libx264 \ # input options
- -i bunny_1080p_60fps.mp4 \ # input url
- -c:v libvpx-vp9 -c:a libvorbis \ # output options
- bunny_1080p_60fps_vp9.webm # output url
This command takes an input file mp4
containing two streams (an audio encoded with aac
CODEC and a video encoded using h264
CODEC) and convert it to webm
, changing its audio and video CODECs too.
We could simplify the command above but then be aware that FFmpeg will adopt or guess the default values for you. For instance when you just type ffmpeg -i input.avi output.mp4
what audio/video CODEC does it use to produce the output.mp4
?
Werner Robitza wrote a must read/execute tutorial about encoding and editing with FFmpeg.