I am currently using opencv in python to write a video with compression. Here are some parts of the code that are giving errors.
fourcc=cv2.VideoWriter_fourcc(*'X264')
video = cv2.VideoWriter(outfiles[c],fourcc, fps, (width,height))
The error is
OpenCV: FFMPEG: tag 0x34363258/'X264' is not supported with codec id 28 and form at 'mp4 / MP4 (MPEG-4 Part 14)' OpenCV: FFMPEG: fallback to use tag 0x00000021/'!???' Working on file test_videos/solidYellowLeft.mp4 OpenCV: FFMPEG: tag 0x34363258/'X264' is not supported with codec id 28 and form at 'mp4 / MP4 (MPEG-4 Part 14)' OpenCV: FFMPEG: fallback to use tag 0x00000021/'!???'
I have downloaded the openh264-1.6.0-win64msvc.dll file for the newer versions of H264 encoding. I've tried different types, H264, X264, XVID, VIDX, not using MJPG because it produces a large file. Setting the 5th option in VideoWriter to False (making it single channel) didn't work either. If you have a suggestion on how to fix this or to try an alternative method, that would help greatly.. If you need any more information, let me know.
If anyone came across this error, I solved it by using the fallback tag which removed the error.
fourcc=0x00000021
Assuming outfiles[c]
contains a filename like "out.mp4"
the following worked for me on an Ubuntu 16.04 machine with an NVidia GPU.
fourcc = cv.VideoWriter_fourcc(*"mp4v")
video = cv2.VideoWriter(outfiles[c],fourcc, fps, (width,height))
Cheers to jspiers for answering here.
User contributions licensed under CC BY-SA 3.0