'Writing video in mp4 format with opencv python
i can save the video in .avi format.but i am unable to write the video in mp4 format. i m using opencv3
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('output.avi',fourcc, 20.0, (640,480))
above portion of code saves the video in .avi format.
Solution 1:[1]
for making mp4 videos you can
VideoWriter_fourcc(*'MP4V')
you can see all fourcc codecs in https://www.fourcc.org/codecs.php
Solution 2:[2]
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
and I don't get any errors.
if using fourcc = cv2.VideoWriter_fourcc(*'MPV4'), I get
OpenCV: FFMPEG: fallback to use tag 0x7634706d/'mp4v'
Solution 3:[3]
Follow this link:
you should replace:
fourcc = cv2.VideoWriter_fourcc(*'XVID')
by:
fourcc = cv2.VideoWriter_fourcc(*'FMP4')
I tried and succeeded.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | 2003G35 |
Solution 3 | M.Vu |