Can't write .mp4 files - Could not open codec 'libx264': Unspecified error

asked 2015-02-09 06:24:21 -0600

margaridamfo.gomes gravatar image

updated 2015-02-11 06:53:49 -0600

Hi everyone!

Days ago I installed the latest 2.4 branch withou ffmpeg. I'm using Ubuntu 14.04 and I don't have at all ffmpeg in my Virtual Machine.

I want to write .mp4 video files and the input files are also .mp4. The input codec is avc1.

I can't obtain any results, the errors can be seen below.

Error:

[libx264 @ 0x9357bc0] broken ffmpeg default settings detected
[libx264 @ 0x9357bc0] use an encoding preset (e.g. -vpre medium)
[libx264 @ 0x9357bc0] preset usage: -vpre <speed> -vpre <profile>
[libx264 @ 0x9357bc0] speed presets are listed in x264 --help
[libx264 @ 0x9357bc0] profile is optional; x264 defaults to high
Could not open codec 'libx264': Unspecified error
Could not open the output video for write: /home/margarida/exams_2014/Output.mp4

Simplified Code:

        int main(int argc, char *argv[]) {
            VideoWriter outputVideo;

            // Get Codec Type
            int ex = static_cast<int>(cap.get(CV_CAP_PROP_FOURCC));

            // Transform from int to char via Bitwise operators
            char EXT[] = { (char) (ex & 0XFF), (char) ((ex & 0XFF00) >> 8),
                            (char) ((ex & 0XFF0000) >> 16), (char) ((ex & 0XFF000000)
                                    >> 24), 0 };

            // Acquire input size
            Size S = Size((int) cap.get(CV_CAP_PROP_FRAME_WIDTH),
                            (int) cap.get(CV_CAP_PROP_FRAME_HEIGHT));

            cout << "Input codec type: " << EXT << endl;

            // Open the output
            outputVideo.open(newname, ex, cap.get(CV_CAP_PROP_FPS), S, true);

            if (!outputVideo.isOpened()) {
                cout << "Could not open the output video for write " << endl;
                        return -1;
                    }

                    while (true) {
                        cap >> frame;
                        if (frame.empty()) {
                            cerr << "nao apanhou frame" << endl;
                            break;
                        }

                        cinzento = acinzentar(frame);
                        imshow("Cinzento", cinzento);

                        outputVideo.write(cinzento);

                        switch(waitKey(10)){

                        case 27:
                            //'esc' has been pressed (ASCII value for 'esc' is 27)
                            //exit program.
                            return 0;

                        }
                    }
                   return 0;
                }

My cmake was this:

cmake -D WITH_TBB=ON -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_VTK=ON -D WITH_FFMPEG=OFF -D WITH_IPP=OFF ..

Can anyone help solving my problem? Thanks in advance :)

If there is no solution please respond.

edit retag flag offensive close merge delete

Comments

Is there any information missing? Please help!

margaridamfo.gomes gravatar imagemargaridamfo.gomes ( 2015-02-16 08:38:25 -0600 )edit

Did you find out a solution to this one?

Sumit Srv gravatar imageSumit Srv ( 2016-07-08 05:46:33 -0600 )edit