To use OpenCV's VideoWriter
class to write an H264 encoded video, one would encounter some error like
Could not open codec libx264: unspecified error
Here is the trick. Beforehand, one has to make sure
--enable-libx264
is switched on in ffmpeg- OpenCV is downloaded in sources.
Then make following changes to modules/highgui/src/cap_ffmpeg_impl.hpp
:
...
c->bit_rate = (int)lbit_rate;
/************** modifications to enable x264 writer ************************/
c->me_range = 16;
c->max_qdiff = 4;
c->qmin = 1;
c->qmax = 30;
c->qcompress = 0.9;
c->qcompress = 0.6;
/************** end of modificaiton ****************************************/
/* open the codec */
if ((err=
#if LIBAVCODEC_VERSION_INT >= ((53<<16)+(8<<8)+0)
avcodec_open2(c, codec, NULL)
#else
avcodec_open(c, codec)
#endif
) < 0) {
fprintf(stderr, "Could not open codec '%s': %s", codec->name, icvFFMPEGErrStr(err));
return false;
}
Compile OpenCV, then you will be able to use the VideoWriter with FOURCC H264
.
can you show how it can be accomplished with https://github.com/justadudewhohacks/opencv4nodejs