-
Notifications
You must be signed in to change notification settings - Fork 5.8k
about how to use cv2:: codacodec:: VdieoReader::set() #3944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
cc @cudawarped |
@RookieDeng33 You can seek to an initial frame position when initializing the decoder, see this test, however If there is a small gap between the frames you require then I would just decode and skip the intermediate frames. This could be equivalent to seeking if the gap between those frames is less than the gap between key frames. e.g. If you want frames 10,20,30,...,100 but the key frame is every 250 frames the internal logic when seeking would have to decode all of the frames from frame 0 anyway making the current behaviour of |
Thank you for your reply, which has helped me a lot; However, I still have some doubts. Why not reset the queue but recreate the cudacodec:: VideoReader instance; For video files, is it more efficient to reset the queue than to reload the video source? |
I am not clear on your what you are asking? To clarify I am not suggesting you create a new instance of I am also pointing out that when you skip to a frame in between key frame the decoder has to decode every frame from that key frame to your desired frame anyway. This means that depending on your use case (how close together the frames you want to skip to are and the GOP size etc.) you can simply decode all the frames and ignore the ones you don't need. |
Sorry for not describing my problem clearly. Parameter frames_idx of function get_cap_frames_by_range is a batch of consecutive video frame idx. For example, the first batch of frames_idx is [1,2,3,4,5], and the second batch may be [4,5,6,7,8] , and the third batch may be [9,10,11,12]. I mean that when decoding each batch, it may need to create a new instance of cudacodec::VideoReader, but not necessarily. |
@RookieDeng33 I still don't fully understand what you are asking. That said if you altered the implementation so that you could seek to a specifiec location within the file during decode then it should be more efficient to do that than create a new instance of |
How to use similar functions in cv2:: codacodec:: VdieoReader like cv2:: VideoCapture:: set (CAP_PROP_POS_FRAMES, target)
I need to read the video frame from the customized key frame position, or repeat the reading from the specified frame when reading the video to the last frame
just like
The text was updated successfully, but these errors were encountered: