Repository navigation
Add close() and context manager support to VideoStream - #587
Open
vishal-tambi wants to merge 2 commits into
Open
vishal-tambi wants to merge 2 commits into
vishal-tambi wants to merge 2 commits into
Conversation
| stream = auto_close(vs_type(get_absolute_path("resources/testvideo.mp4"))) | ||
| with pytest.raises(RuntimeError, match="raised in with block"), stream: | ||
| raise RuntimeError("raised in with block") | ||
| with pytest.raises(ValueError): |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a public
close()method andwithsupport toVideoStream, so callers can release file handles and decoders right away instead of waiting for garbage collection (fixes #568). The base method does nothing, so existing subclasses keep working, while the OpenCV, PyAV, MoviePy and concat backends release their resources and raiseValueErrorif used after closing. Properties likepath,frame_rate,durationandframe_sizestill work after closing, because each backend records them inclose()just before it releases the handle.VideoStreamConcatnow also closes each input once it is done with it, including when construction fails, which used to leave every input open.