2

Here is my link format to HTTP stream(user, password and address was changed to dummy):

http://username:password@192.168.0.104:8093/axis-cgi/mjpg/video.cgi

This stream works perfectly in VLC. However, I can't open it using OpenCV library.

Here is my code:

#include <iostream>
#include "opencv2/opencv.hpp"

using namespace std;
using namespace cv;

int main()
{
    VideoCapture cap;
    const string videoStreamAddress = "http://username:password@192.168.0.104:8093/axis-cgi/mjpg/video.cgi";
    cap.open(videoStreamAddress);
    if (!cap.isOpened())
    {
        cout << endl << "Videostream not found !" << endl;
        system("pause");
        return 0;
    }

    Mat frame;

    while(1)
    {
        cap >> frame;
        if (frame.empty())
            break;

        imshow("IPcamera", frame);

        int c = waitKey(1);
        if (c == 27)
        {
            break;
        }
    }

    waitKey(0);
    return 0;
}

This gives me an error:

warning: Error opening file (../../modules/highgui/src/cap_ffmpeg_impl.hpp:529)

which points to:

bool CvCapture_FFMPEG::open( const char* _filename )
{
    unsigned i;
    bool valid = false;

    close();

#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(52, 111, 0)
    int err = avformat_open_input(&ic, _filename, NULL, NULL);
#else
    int err = av_open_input_file(&ic, _filename, NULL, 0, NULL);
#endif

    if (err < 0)
    {
        CV_WARN("Error opening file");
        goto exit_func;
    }
...

What could be a problem?

OpenMinded
  • 1,175
  • 2
  • 9
  • 24

1 Answers1

0

Did you try opening a video file in your machine using Videocapture? (Just add the path to the video file to the place where you've put the URL) I assume that it fails in the same way. So this is a problem with ffmpeg. You'll need to build OpenCV yourself with ffmpeg support. (Do some search on gstreamer as well. I'm not much familiar with that).

Also you can try using another software like ManyCam in the middle. It enables you to read the stream easily in the same way you are reading from a webcam.

Sanj
  • 65
  • 7