x

Learning FFmpeg

19 June 2023

If you are working with videos on a regular basis ffmpeg might prove to be an invaluable tool. FFmpeg is a video and audio conversion/recording commandline tool that also supports streaming. Cli tools might not be the easiest to use but can provide some extremly powerful automation possibilities.

the most basic command is aready idefintly useful:

converting a videos

ffmpeg -i input.mkv output.mp4

mp4 and mkv are containers

converting a raw file into a compressed file

ffmpeg \
  -i raw.prores \          # input
  -c:v libaom-av1 4000k \  # video codec
  -c:a opus 64k \          # audio codec
  output.mp4               # output

example for web upload

Create a video out of single frames

Let's say you render an animation with each frame as an individual image. Once you are done postprocessing them, ffmpeg can create video. Here is how to do it:

  ffmpeg 
    -framerate 24 \
    -i "frame_%03d.exr" \     # %3d matches any number with 3 digits
    -c:v libaom-av1 4000k \
    -pix_fmt yuv420p \
    outputfile.mp4

-pix_fmt defines the pixel format