I have used python and OPENCV with CPU to make a statement like this:
out = cv2.gpu.VideoWriter_GPU.VideoWriter_GPU('videoOut.mp4',cv2.VideoWriter_fourcc(*'mp4v'), 15, size)
However, it is very slow since it is using the CPU. How do you create a video with CUDA to use the GPU?