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

Feature request: Add seek by time stamp (Same question with issue#232) #561

Description

@chenj133

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions