Search code examples
ffmpeg

Create thumbnails tile for time range of video


I need to create, let's say, 12 thumbnails from video, but skip 10 percent in the beginning and in the ending. I found this thing, but it just takes every 1000th frame. In my case this range will be variable and it will be better if it will be in seconds. Can't figure out how to do this with ffmpeg, don't work with it much.


Solution

  • ffmpeg -ss $skip_time -i $input_path -vframes 1 -vf select=isnan(prev_selected_t)+gte(t-prev_selected_t\,$screenshot_time), scale=iw*min($width/iw\,$height/ih):ih*min($width/iw\,$height/ih),pad=($width):($height):($width-iw)/2):($height-ih)/2),tile=3x4 -vcodec mjpeg $output_filename
    

    $skip_time - time to skip from the beginning $screenshot_time - time interval for screenshots to be taken

    These values should be precalculated, I used ffprobe to get video duration.