1

Topic: Create thumbnails every X frames/seconds/minutes with ffmpeg

Since I struggled to find some infos for this, I wanted to sum up my findings here:

ffmpeg -y -threads 8 -i "test.m4v" -an -sn -vsync 0 -vf select="not(mod(n\,14386))" -s 854x480 -vcodec mjpeg -pix_fmt yuvj420p -b:v 2000 -bt 20M "test_%d.jpg"

explanation:

  • -y
    overwrite output, if already exists

  • -threads X
    X = number of threads used during decoding

  • -i "path to input"
    specifies the input

  • -an
    disables the audio

  • -sn
    disables subtitles

  • -vsync 0
    disables a/v sync

  • -vf select="not(mod(n\,X))"
    only outputs every Xth frame, so if you want to create a thumbnail select every Y minute set X = Y*60*fps e.g. 10*60*23.967 = 14380

  • -s WIDTHxHEIGHT
    sets the resolution for the output; this should only be needed if your input is anamorph

  • -vcodec X
    sets the output format, typically mjpeg or png

  • -pix_fmt X
    sets the output color space typically yuvj420p or rgb24

  •   -b:v X -bt Y
    sets the target bitrate and the bitrate tollerance X = 2000 and Y = 20M seem to be good values

  • "path to output ending with _%d.extension"
    specifies the output file, where _%d is used so the output will  look like fileName_0, fileName_2,...
    .extension should be .jpg or .png

If you want to:

  • Create a single thumbnail every X frames/seconds/minutes, but skip the first X seconds, simply add -ss X to the above example.

  • Create a X thumbnails starting from specific time, remove the -vf select="not(mod(n\,X))" part and insert -vframes X -ss timeInSeconds instead, e.g. -vframes 1 -ss 10 would create a single thumbnail after 10 seconds.

Cu Selur