VideoWriter.open silently failing when trying to use h264 / x264
I'm trying to record and encode a video using openCV's VideoWriter class. I can successfully record an .avi file using CV_FOURCC('M','J','P','G'), but no mp4 options work. VideoWriter.open just fails (the function returns False), and I don't know what I'm doing wrong.
I'm using Ubuntu 16.04 and opencv 3.4.1 and writing in C++. With 'X', '2', '6', '4', or 'M','P','4','V', or any of the other variants I've found online, VideoWriter.open() fails. For x264, I've downloaded and built Cisco's open-source openH264, but I don't know how openCV knows to look for it, so I imagine that is a possible cause of my problems. I've tried putting the built executable in the same directory as my program, and I've tried adding the build directory of openH264 to my path, but neither has helped.
myVideoWriter.open(filenameWithMP4Extension, CV_FOURCC('X','2','6','4'), myFramesPerSecond, myFrameSize)
I don't know linux but about ffmpeg I think you can read this. i think (may be I'm wrong) openh264 cisco is only for windows