I tried using the VideoWriter for the first time and get this effect:
Read an AVC1/ yuv4:2:0 movie frame by frame with VideoCapture. (Do nothing with the frames) Write them out as AVC1/ yuv4:2:0 again.
No matter if and which value for VIDEOWRITER_PROP_QUALITY I set the output size is about 6 times as big, and the quality is really bad.
When running the code it says:
OpenCV: FFMPEG: tag 0x31435641/'AVC1' is not supported with codec id 28 and form at 'mp4 / MP4 (MPEG-4 Part 14)'
OpenCV: FFMPEG: fallback to use tag 0x31637661/'avc1'
Failed to load OpenH264 library: openh264-1.7.0-win64.dll
Please check environment and/or download library: https://github.com/cisco/openh264/releases
[libopenh264 @ 0000000002646aa0] Incorrect library version loaded
Could not open codec 'libopenh264': Unspecified error
I use openCV v.3.4.10.
When I provide openh264-1.7.0-win64.dll it says:
OpenCV: FFMPEG: tag 0x31435641/'AVC1' is not supported with codec id 28 and form at 'mp4 / MP4 (MPEG-4 Part 14)'
OpenCV: FFMPEG: fallback to use tag 0x31637661/'avc1'
OpenH264 Video Codec provided by Cisco Systems, Inc.
and produces the strange AVC1 file mentioned above.
My code:
Mat frame;
string strFileName;
VideoCapture capt(strFileName); // YUV4:2:0
Size refS = Size((int) capt.get(CAP_PROP_FRAME_WIDTH),
(int) capt.get(CAP_PROP_FRAME_HEIGHT));
const size_t nNumberFrames (capt.get(CV_CAP_PROP_FRAME_COUNT));
VideoWriter VW ("Unchanged.mp4", CV_FOURCC('A','V','C','1'), capt.get(CV_CAP_PROP_FPS), refS); // YUV4:2:0, extremly bad visual quality, also very big size
for (size_t i = 0; i < nNumberFrames; i++) {
capt >> frame;
VW.write (frame);
}
capt.release();
What is going on here? What is the right code?