Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(convert): release VideoCapture
  • Loading branch information
jeertmans authored Oct 18, 2023
commit 829d28534600bab1255e48008ee81be3b5bd71d5
2 changes: 2 additions & 0 deletions manim_slides/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ def read_image_from_video_file(file: Path, frame_index: FrameIndex) -> Image:
cap.set(cv2.CAP_PROP_POS_FRAMES, index - 1)

ret, frame = cap.read()
cap.release()

if ret:
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
Expand Down Expand Up @@ -495,6 +496,7 @@ def xpath(el: etree.Element, query: str) -> etree.XPath:
def save_first_image_from_video_file(file: Path) -> Optional[str]:
cap = cv2.VideoCapture(file.as_posix())
ret, frame = cap.read()
cap.release()

if ret:
f = tempfile.NamedTemporaryFile(mode="w", delete=False, suffix=".png")
Expand Down