What is the video codec for mp4 in OpenCV 4.1.1.26?
I'm trying to write videos from two cameras, writing AVI video is working fine but writing the mp4 video is not working.
- Python 3.7
- OpenCV 4.1.1.26
- Windows 10
Below is sample code for one camera
cap = cv2.VideoCapture(0)
fourcc = cv2.VideoWriter_fourcc(*'DIVX')
out = cv2.VideoWriter('output_1.mp4', fourcc, 15, (640, 480))
I used different codecs (MPEG, H264, mp4v, ('m','p','4','v'), FFmpeg etc.) as in OpenCV 4 Documentations , FOURCC Codecs Documentations and suggested by different experts and helpers on different platforms but any solution is not working in my code, mp4 video is saved but can't be played in any media player even in OpenCV VideoCapture due to problem in codec. On other hand when I save avi video, it works fine. I checked these links to get help.
what is the codec for mp4 videos in python OpenCV
How to write mp4 video file with H264 codec?
Looking for valuable suggestions.