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:

  1. global options
  2. input file options
  3. input url
  4. output file options
  5. 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:

  1. # WARNING: this file is around 300MB
  2. $ wget -O bunny_1080p_60fps.mp4 http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_60fps_normal.mp4
  3.  
  4. $ ffmpeg \
  5. -y \ # global options
  6. -c:a libfdk_aac -c:v libx264 \ # input options
  7. -i bunny_1080p_60fps.mp4 \ # input url
  8. -c:v libvpx-vp9 -c:a libvorbis \ # output options
  9. 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.