【问题标题】:Can't open HTTP stream: Error opening file (../cap_ffmpeg_impl.hpp:529)无法打开 HTTP 流:打开文件时出错 (../cap_ffmpeg_impl.hpp:529)
【发布时间】:2013-11-18 23:53:58
【问题描述】:

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

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

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

这是我的代码:

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

可能是什么问题?

【问题讨论】:

  • 运气好吗??我也有同样的问题
  • @OpenMinded 我遇到了类似的问题 - 你找到解决方案了吗?

标签: c++ opencv video-streaming


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-04-02
    • 2015-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-14
    • 2019-02-10
    相关资源
    最近更新 更多