Extract X Frames From Specific Times to JPG Files

0
0
https://ffmpeg-by-example.s3.amazonaws.com/extract-frames-at-time.jpg
ffmpeg -i video.mp4 -vf "select=(eq(22.0\,t))+(eq(32.0\,t))+(eq(84.0\,t))+(eq(98.0\,t))+(eq(120.0\,t)),setpts=N/FRAME_RATE/TB" -f image2 output/%03d.jpeg

2 comments
Anonymous
Markdown is supported
@tordenflesk
tordenfleskcommented2 months ago

If you only need a single image from a bunch of files and you don't want to spend ~5 minutes per image:

ffmpeg -hide_banner -loglevel error -n -ss %num% -i "%%~f" -frames:v 1 -an "%out_path%%%~nf.png"

@eladg
eladgcommented2 months ago

You example indeed works and I use it literally daily(!), but it does not solve the described problem (extracting multiple frames 😄).

The only reason you will need to 'spend ~5 minutes per image' is because of seeking to the right time on a large file. Your solution solves it by putting the -ss time ahead of the input.

On a project I worked on last week, I needed to extract specific frame numbers from a file - and I did not know at what specific time they are going to play. I used the "eq(n\\,33),eq(n\\,44),eq(n\\,55)" expression to grab the 33, 44 and 55 frames.

Question @tordenflesk : what are all these % symbols? is that PowerShell or something?