I'm trying to use opencv videoWriter to get a video file. But I get the following problem:
>[libx264 @ 0x132b680] broken ffmpeg default settings detected
>[libx264 @ 0x132b680] use an encoding preset (e.g. -vpre medium)
>[libx264 @ 0x132b680] preset usage: -vpre <speed> -vpre <profile>
>[libx264 @ 0x132b680] speed presets are listed in x264 --help
>[libx264 @ 0x132b680] profile is optional; x264 defaults to high
>Could not open codec 'libx264': Unspecified error!!! Output video could not be opened
I do have libx264 in my system, so I guess this last line is just a side effect
The code i'm trying to run is an example taken from How to write video file in OpenCV 2.4.3 .
int main (int argc, char *argv[]){
// Load input video
VideoCapture input_cap("testi.mp4");
if (!input_cap.isOpened())
{
std::cout << "!!! Input video could not be opened" << std::endl;
return -1;
}
// Setup output video
cv::VideoWriter output_cap("testo.mp4",
input_cap.get(CV_CAP_PROP_FOURCC),
input_cap.get(CV_CAP_PROP_FPS),
cv::Size(input_cap.get(CV_CAP_PROP_FRAME_WIDTH),
input_cap.get(CV_CAP_PROP_FRAME_HEIGHT)));
if (!output_cap.isOpened())
{
std::cout << "!!! Output video could not be opened" << std::endl;
return -1;
}
// Loop to read from input and write to output
cv::Mat frame;
while (true)
{
if (!input_cap.read(frame))
break;
output_cap.write(frame);
}
input_cap.release();
output_cap.release();
return 0;
}
I found a post with a similar problem How to get stream info from opened file in ffmpeg? but no one answered correctly yet.
I've found people are told to check if opencv is using old fmmpeg instead of libav, which it isn't since it's a fresh build and my ubuntu doesn't have ffmpeg.