How to save a video using OpenCV VideoWriter to a specific directory -- python
Try
fourcc = cv2.VideoWriter_fourcc(*'MP4V')
instead of
fourcc = cv2.VideoWriter_fourcc(*'XVID')
When you call the function
cv2.VideoWriter("/your/path/filename.mp4",fourcc, 20,(320,180))
I hope it helps :)