kkroening/ffmpeg-python

How to get frames & their timestamps - frame-pts option?

freeIsa opened this issue · 3 comments

Hi everyone,
I am experimenting with different ways to sample a fixed number of frames from a video. At the same time, I would also need to get the timestamps of the extracted frames so as to save them in a dataframe.

What's the best way to achieve this? Right now, the only way I found is to use the showinfo filter and parse the output string (as shown here).

According to ffmpeg docs a frame_pts option should also be available that would use timestamps in the saved frame filenames (which would not be ideal either, as I would still have to parse filenames to get them, but it's an alternative), but I don't seem to get it to work in ffmpeg-python. Can someone suggest the right syntax per this option?

In general, if you can suggest how to get selected frames and their timestamps in one pass that'd be really appreciated 🙏