This repository was archived by the owner on Jun 10, 2024. It is now read-only.

Description
I want to decode a frame each second.
the request is same with issue_232(#232)
the answer is a little old.
how can I find the seek func on master branch recently?
I find the seek_timestamp in tests/test_PyFfmpegDemuxer.py, but the output is on cpu,I don't want to decode to cpu,because I will send into tensorrt model.
how can I seek with timestamp now?
in opencv,it likes:
while was_read and cap.get(cv2.CAP_PROP_POS_FRAMES) + cap_fps < total_fram_count:
cap_time = int(cap.get(cv2.CAP_PROP_POS_MSEC))
q.put((cap_time, frame_count, img))
for i in range(int((frame_count + 1) * cap_fps) - int(frame_count * cap_fps)):
if cap.get(cv2.CAP_PROP_POS_MSEC) >= (frame_count + 1) * 1000:
break
cap.grab()
was_read, img = cap.retrieve()
frame_count += 1
I retrieve CAP_PROP_POS_FRAMES and check CAP_PROP_POS_MSEC at the same time because some video CAP_PROP_POS_FRAMES is not right. for example, CAP_PROP_POS_FRAMES is 25,but the 25th frame's CAP_PROP_POS_MSEC is 0.83s