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.