1. Home
  2. Docs
  3. ffmpeg
  4. ffmpeg examples
  5. Frame rendering: movie => images

Frame rendering: movie => images

Minimal example: ffmpeg -i [input file] [options] [output file template]

Possible options:

  • -r [fps]: if you need all frames, you can skip using this. if you only need e.g. 2 frames per second (when you’re looking for a nice screenshot), use -r 2.
  • -s [wxh]: if you need the original size, don’t use this. To resize to e.g. HD: -s 1920x1080. Remember that resizing always keeps the aspect ratio. So if the original is 2000×2000 pixels (square), after resize -s 1920x1080, it will be 1080×1080. It is possible to force resize -s 1920x1080!, but that might squeeze your picture. Another option is using letterboxing or pillarboxing.
  • -ss [start] -t [length]: if you don’t need the frames of the whole video, but only the part that starts at second [start] and stop [length] seconds after that.
  • output file template:
    • decide on what image file type you want. For the lossy compressed ones (.JPG, .PNG, …) be sure to define the quality level you need. For the uncompressed ones (.BMP, .TIFF), make sure you have enough storage space. E.g. 3 x 10-bit color TIFF at 25 fps will take 97 MB of data per second.
    • estimate how many digits you need for all the frames with [secs] x [fps]. Example: 30 secs x 25 fps = 750 frames, so you need at least 3 digits %03d; 90 minutes at 2 fps = 5400 x 2 = 10800 frames, so at least 5 digits %05d.

Example:

ffmpeg -i input.mov -r 5 -s 1920x1080 -ss 2 -t 10 -qscale 1 -y frames/f_%05d.jpg
Tags , ,