My goal is to extract each frame timestamps of an video (it can be an mkv, mp4, avi, etc). I parse the result in python, so I can map the frame 1 to 42 ms, frame 2 to 83 ms, etc...
I have tried these 2 commands:
ffprobe -select_streams 0 -show_entries packet=pts_time -print_format json VIDEO.mkv
ffprobe -select_streams 0 -show_entries frame=pts_time -print_format json VIDEO.mkv
They seems to always return me the same result, but the first one is faster. So, should I always use packet=SOMETHING?
Some video doesn't have pts_time. Should I use always dts_time or even best_effort_timestamp_time instead of pts_time?
Finally, the time from pts_time, dts_time and best_effort_timestamp_time seems to always be in seconds. Is there a way to get it in milliseconds?
Strictly speaking, frame timings are the correct attribute. It's possible but uncommon for multiple frames to be carried in one packet, or for a frame to be split (as slices) across multiple packets. But most of the time, you can use packet attributes.
The
*_timefields are all printed as decimal seconds only. You can read the raw timestamps i.e.pts, but then you will have to multiple with the streamtime_basex1000to get milliseconds.