Ask Your Question

Revision history [back]

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. Below is simplified but representative code of what I'm currently trying. I'm obviously skipping a lot of details of my context and frame-grabbing, but that all works with avi so I don't think that is the problem. With 'X', '2', '6', '4', or 'M','P','4','V', or any of the other variants I've found online, VideoWriter.open() fails, so that is the problem spot. 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.

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. Below is simplified but representative code of what I'm currently trying. I'm obviously skipping a lot of details of my context and frame-grabbing, but that all works with avi so I don't think that is the problem. With 'X', '2', '6', '4', or 'M','P','4','V', or any of the other variants I've found online, VideoWriter.open() fails, so that is the problem spot. 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)

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. 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)