cv2.VideoCapture.read freezes

Hi! I am using a HQ camera and a raspberry pi4.
My code acquires 10s video using Picamera2 video recording function. Than, I load the mp4 video just recorded and I use cv2.VideoCapture to read video and process it (apply a mask for background subtraction).
My problem is that cap.read() freezes at the first frame.

Anyway, if I give the same mp4 video as input of a function that does exactly the same things (read video and process), it does not freeze, the code works.

The video is the same, why in the workflow of video recording and processing does not work using one unique script?

Nobody knows, because you don’t even show the script that freezes!

(Most likely: you need to release() the writer after capturing the video.)