gpt4 book ai didi

c++ - 无法打开 HTTP 流 : Error opening file (. ./cap_ffmpeg_impl.hpp:529)

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:55:37 25 4
gpt4 key购买 nike

这是我的 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;
}
...

可能是什么问题?

最佳答案

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

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

关于c++ - 无法打开 HTTP 流 : Error opening file (. ./cap_ffmpeg_impl.hpp:529),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19834202/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com