Home>
cv :: VideoCapture movie ("videos/janken.mp4");
    if (! movie.isOpened ()) {
        cout<<"Movie not found!"<<endl;
        return -1;
    }



g ++ $(pkg-config --cflags --libs opencv) test.cpp -o Test
Open the Test file generated by compiling with

OpenCV: Couldn't read video stream from file"videos/janken.mp4"
Movie not found!
logout
Saving session ...
... copying shared history ...
... saving history ... truncating history files ...
... completed.

[Process is complete]

is displayed. What are the reasons for not opening a video file? I'm a beginner in programming and I don't know, so I'd like to ask you to teach me.

c++
  • Answer # 1

    In the first place, does ./videos/janken.mp4 exist in the program execution location?
    From the expression of opening Test, I think it is like Windows, but when running from Explorer, the current changes, so it is better to describe it with an absolute path.
    Or get the path of the executable and make it relative to it.

    Or, the DLL for reading MP4 is not working properly
    Not be able to install, such as the path is not through

  • Answer # 2

    Hello.

    I don't know if OpenCV supports mp4, but it's likely not. In other words, I suspect that the cause is not supporting mp4.

    The mp4 license is troublesome because it involves a patent.