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:
- OpenCV VideoWriter Failed to Start [How to Solve]
- [Solved] ffmpeg error reporting: subprocess. Calledprocesserror: Command ‘ffmpeg, unknown encoder: “libx264″“
- [Solved] Cmake compile opencv open-source project Error: but it set OpenCV_FOUND to FALSE so package “OpenCV” is considered to be…
- [Solved] Opencv3. X fatal error: opencv2/nonfree/nonfree.hpp: there is no such file or directory
- How to Solve Pandas Error: nested renamer is not supported python
- Opencv Can not Find opencv2/gpu/gpu.hpp [How to Solve]
- RuntimeError: Exporting the operator uniform to ONNX opset version 12 is not supported.
- tf.nn.dilation2d Call Error: TypeError: dilation2d_v1() got an unexpected keyword argument ‘data_format’
- Json: struct field readyReplicas has json tag but is not exported [How to Solve]
- [Solved] MacOS Compile ffmpeg Error: ERROR: openssl not found
- [Solved] bin/hive Startup Error: Operation category READ is not supported in state standby
- [ERROR Swap]: running with swap on is not supported. Please disable swap
- TypeError: unsupported format string passed to numpy.ndarray.__format__
- [Solved] ffmpeg Enable https Error: “ERROR: openssl not found”
- [Solved] OpenCV error: #error “This header with legacy C API declarations has been removed from OpenCV.
- [Solved] ORB_SLAM3 Compile Error: opencv4.0 not found four
- [Solved] Android Project error: import android.support.v4 (V7). App.activitycompat
- [Solved] Opencv Calls PB Model Error: cv2.error: OpenCV(4.2.0)…
- Docker Error response from daemon: Get https://registry-1.docker.io/v2/: x509: certificate has expired or is not yet valid