ffmpeg extract frame timestamps from video

TheOtherguyz4kj picture TheOtherguyz4kj · Nov 25, 2017 · Viewed 9.8k times · Source

I am using this library to use FFmpeg with my Android application. I am extracting frames from a video and then adding them to a crop viewer. So each frame needs to represent some time frame within the video. Here is my current ffmpeg code to extract the frames:

ffmpeg -i inputFile -f image2 -ss mySS -r myR frame-%05d.png

When using the above command how would I add a timestamp to each frame? So i know for example frame 5 is at 9s within the video.

I dont know if the ffmpeg lib I am using has ffprobe from this link. I have also looked at other links on stackoverflow

any help is appreciated

Answer

hoohoo-b picture hoohoo-b · Jul 12, 2019

frame_pts option is your friend... set it to true and ffmpeg will output the frame's presentation timestamp as your filename.

ffmpeg -skip_frame nokey -i file -vsync 0 -frame_pts true out%d.png

Credits goes to this superuser answer.. more explanation of mixing framerate -r option with frame_pts