Hello sir,
I am sorry for the late reply. I have been trying to check whether the problem might be related to OpenCV.  Unfortunately, I still could not solve it. The code does run. However, the saved video after processing using the Pytorch model is empty. I still can not figure out what might be the cause.