I am trying to get OpenCV VideoWriter work across platform consistently for MP4 container with H246 encoding.
Target platforms in order of importance - Ubuntu, Raspbian, OSX
Basically, my shortcoming at this point is not understanding the relationship of FourCC code (as a parameter to OpenCV VideoWriter) to the FFMPEG backend and its requirements. I am interested to understand the game in play rather than discussing a piece of code.
What I want to know is when I specify 'X264' as FourCC code trying to write an x.MP4 file (FFMPEG backend) and the request is marshalled to FFMPEG what requirements/dependencies need to be satisfied by the OS for it to success.
So far I have got my python stack writing MP4 video files across Raspbian/Ubuntu/OSX, with a hack.
On my Raspbian stretch installation, I use 0x00000021 as the fourCC code. On Ubuntu (VM on OSX) and on OSX, AVC1 works.
Days of Googling only delivered those hacks, not a good understanding of the problem.
The x264 as FourCC code leads to one of - failure, non-portable video file + annoying FFMPEG warning.
I am trying to get to the bottom of it.
The code,
#self.__fourCC = cv2.VideoWriter_fourcc('x', '2', '6', '4')
self.__fourCC = cv2.VideoWriter_fourcc('a', 'v', 'c', '1')
if PlatformUtils.isRunningOnRaspberryPi():
self.__fourCC = 0x00000021
I have control over the version both OpenCV and FFMPEG (if required GStreamer too). I can and have built them for Ubuntu/Raspbian.
User contributions licensed under CC BY-SA 3.0