Could you try to remove the PyTorch code and just create the video output using random numpy arrays with the same shape and dtype as in your current code?
I think this issue might be more related to OpenCV than PyTorch and you might need to e.g. permute the arrays before storing them.