简体   繁体   中英

FFMPEG - extract two consecutive frames

I need to use FFMPEG to randomly select time (eg 0:10) and save two consecutive frames as PNG.

HOW TO SAVE FRAME TO PNG:

ffmpeg.exe -ss 0:10 -y -i test.avi -vcodec png -vframes 1 -an -f rawvideo test.png

HOW TO EXTRACT INFO ABOUT THE VIDEO FILE:

ffprobe -v error -select_streams v:0 -show_entries stream=duration,avg_frame_rate -of default=nw=1:nk=0 test.avi

Output:

avg_frame_rate=120/1
duration=59.808333

QUESTION

How to determine next frame? Frame rate 120/1 means 120 frames per second?

EDIT

Possible solution - am I correct that extracting the frames at times +(1/120 = 0.00833333) would solve my problem?:

-ss 0:10
-ss 0:10.00833333

Does it guarantee exactly the next frame? Is there any other approach?

Use the image sequence muxer

ffmpeg -ss 0:10 -y -i test.avi -vframes 2 -vsync 0 -an -f image2 test%d.png

This will output test1.png and test2.png, the frames being consecutive.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM