无法打开 HTTP 流:打开文件时出错 (../cap_ffmpeg_impl.hpp:529) [英] Can't open HTTP stream: Error opening file (../cap_ffmpeg_impl.hpp:529)

查看:110
本文介绍了无法打开 HTTP 流:打开文件时出错 (../cap_ffmpeg_impl.hpp:529)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我到 HTTP 流的链接格式(用户、密码和地址已更改为虚拟):

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

此流在 VLC 中完美运行.但是,我无法使用 OpenCV 库打开它.

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

这是我的代码:

#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;
}

这给了我一个错误:

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

指向:

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;
    }
...

可能有什么问题?

推荐答案

您是否尝试使用 Videocapture 在您的机器中打开视频文件?(只需将视频文件的路径添加到您放置 URL 的位置)我假设它以相同的方式失败.所以这是ffmpeg的问题.您需要使用 ffmpeg 支持自己构建 OpenCV.(也可以在 gstreamer 上进行一些搜索.我对此不太熟悉).

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

您也可以尝试在中间使用其他软件,例如 ManyCam.它使您能够像从网络摄像头中阅读一样轻松地阅读流.

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.

这篇关于无法打开 HTTP 流:打开文件时出错 (../cap_ffmpeg_impl.hpp:529)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆