dmlc / dmlc/decord

Explicit close of VideoReader

Open
#222 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
2.5k
Forks
232
PR merge metrics
No merged PRs in 30d

Description

Hey there,

Thanks for the great project, it helped me gain lots of performance :)
I have a little feature request though, since I'm processing multiple mp4 files that I need to move around in my filesystem after I've read them:

```
for file in files:
vr = VideoReader(file)
# ... read and process the frames...

if success:
os.rename(file, other_path)
```

Now this fails on Windows, because the reader is having the file still open:
> PermissionError: [WinError 32] The process cannot access the file because it is being used by another process

I could force the garbage collection (and thus the __delete__ handler) by using:
> del vr

But it would be much better if you could add the required functions to wrap the reader into a [with .. as block](https://docs.python.org/3/whatsnew/2.6.html#pep-343-the-with-statement) that will free the video handle.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.