1. Problem code
A few months ago, a piece of code could be executed normally. Some of the codes are as follows:
def buildVideoByCV():
videoMake = cv2.VideoWriter()
fourcc = cv2.VideoWriter_fourcc(*'MP4V') #https://blog.csdn.net/whudee/article/details/108689420
fps = 12
videoMake.open(r"g:\video\lightShowCV.MP4", fourcc, fps, (800,600))
for t in range(65*fps):
img = makeframe(t*1.0/fps)
videoMake.write(img)
if t%20==0:print(f'\r视频制作进度:{(t*100.0)/(66*fps):4.2f}%',end='')
videoMake.release()
2. Error message
Error in execution today:
Video production progress: 95.96%OpenCV: FFMPEG: tag 0x5634504d/'MP4V' is not supported with codec id 12 and format 'mp4/MP4 (MPEG-4 Part 14)'
OpenCV: FFMPEG: fallback to use tag 0x7634706d/'mp4v'
3. Solution
Set FourCC = cv2.videowriter_FourCC (*'mp4v')
is changed to: FourCC = CV2.Videowriter_FourCC (*'mp4v')
, just change the encoded uppercase mp4v to lowercase.
4. Summary
This paper introduces the solution to the error reported by opencv videowriter: ffmpeg: tag ‘mp4v’ is not supported. You only need to replace the code ‘mp4v’ with ‘mp4v’.
Read More:
- [Solved] Ubuntu uses gym to save the video error: “unknown encoder ‘libx264′”
- [Solved] ffmpeg error reporting: subprocess. Calledprocesserror: Command ‘ffmpeg, unknown encoder: “libx264″“
- srs Error: demux SPS/PPS : avc decode sequence header
- [Solved] Compile the program error: undefined reference to `cv::dnn::dnn4_v20210301::Net::~Net()‘
- OpenCV(-206:Bad flag (parameter or structure field)) Unrecognized or unsupported array type [How to Solve]
- [Solved] Opencv Compile Error: (CMake Error: The following variables are used in this project, but they are set to not)
- [Solved] Opencv3. X fatal error: opencv2/nonfree/nonfree.hpp: there is no such file or directory
- Adjusted frame length exceeds 4096: 5637-discarded server solution
- [Solved] Cmake compile opencv open-source project Error: but it set OpenCV_FOUND to FALSE so package “OpenCV” is considered to be…
- [Solved] FFMPEG live encoding 2. session more error: [nvenc @ 0xa00480] OpenEncodeSessionEx failed: 0xa – invalid license key?
- [Solved] Postman Error: Unsupported Media Type
- Cv2.dnn read model error [How to Solve]
- [Solved] ORB_SLAM3 Compile Error: opencv4.0 not found four
- CMake Error: The source directory “opencv Install Catalog“ does not appear to contain CMakeLists.txt.
- ROS Error: warning: “deprecated pixel format used“
- OpenCV4 Error: imread(argv[1], CV_LOAD_IMAGE_COLOR);
- [Solved] MacOS Compile ffmpeg Error: ERROR: openssl not found
- [Solved] OpenCV error: #error “This header with legacy C API declarations has been removed from OpenCV.
- [Solved] OpenCV Error: AttributeError: module ‘cv2‘ has no attribute ‘data‘
- maven Error: Element ‘dependency’ cannot have character [children], because the type’s content type is