Skip to content
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

Possible mem leak when using queues and consumer thread doesn't keep up with decoding thread. #304

Open
NevermindNilas opened this issue Jun 17, 2024 · 2 comments

Comments

@NevermindNilas
Copy link

NevermindNilas commented Jun 17, 2024

Most of my discussion can be seen here:

python/cpython#120610

@gcanat
Copy link

gcanat commented Jun 27, 2024

Since this library seems unmaintained, I went through the hassle of writing something similar (except it is based on Rust instead of C++). If you want to give it a try: https://github.com/gcanat/video_reader-rs

It has the get_batch method similar to decord, so if you want to get certain frames from a video you can do:

import video_reader
frames = video_reader.get_batch("video.mp4", frame_indices)

Where frame_indices is the list of indices you want. If you only want one frame with index 42 you could do frame_indices=[42]

Additionally, if you want to decode the whole video:

frames = video_reader.decode("video.mp4")

If you want to only get 1 frames out of 4 in the entire video you can do:

frames = video_reader.decode("video.mp4", compression_factor=0.25)

NOTE: regarding your code snippet to benchmark decord you dont even need opencv to get the frame count, once your instantiate the VideoReader object you can do len(vr) to get it. Also, I'm not sure what you are trying to do with a for loop iterating on each frame index. That's not how this library is supposed to be used. You should use the get_batch method instead and get all the frames you want at once.
Anyway, it is true that decord has some memory management issues and that's also why I made video_reader-rs

@NevermindNilas
Copy link
Author

Hello,

Thanks for sharing your project with me.
I will check it out and bring some of my questions to your repo in this case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants