警告:找不到编解码器参数(././modules/higgui/src/cap_ffmpeg_impl.hpp:540)

warning: Could not find codec parameters (../../modules/highgui/src/cap_ffmpeg_impl.hpp:540)

本文关键字:ffmpeg impl hpp cap higgui 编解码器 找不到 参数 警告 modules src      更新时间:2023-10-16

我正在尝试显示来自IP摄像机的视频馈送,得到以下错误

warning: Could not find codec parameters 
(../../modules/highgui/src/cap_ffmpeg_impl.hpp:540)

这是相同的代码。

#include <stdio.h>
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv; 
using namespace std;
int main(int, char**) 
{ 
VideoCapture vcap; 
Mat image;
// This works on a D-Link CDS-932L
const string videoStreamAddress = "http://admin:admin123@172.41.20.55:80/?    action=stream?dummy=param.mjpg";//From mjpeg streamer
//const string videoStreamAddress = "http://192.168.1.13:8080/videofeed?   dummy=param.mjpg"; // Streaming from android using ip-cam
//open the video stream and make sure it's opened
if(!vcap.open(videoStreamAddress)) {

cout << "Error opening video stream or file" << std::endl;
return -1;
}
for(;;) {
if(!vcap.read(image)) {
    cout << "No frame" << std::endl;
    waitKey();
}
cv::imshow("Output Window", image);
    if(cv::waitKey(1) >= 0) break;
}
}

首先我得到了不同的错误,所以我安装了K-Lite编解码器。现在我得到了这个错误。有人能告诉我这个错误和什么有关吗。我已经看了很多来自斯塔克弗洛和opencv的帖子,但也能得到一个令人满意的答案。请帮帮我。提前谢谢。

我用以下代码解决了这个问题。

#include <stdio.h>
#include <opencv2/opencv.hpp>

int main(){
CvCapture *camera=cvCaptureFromFile("http://username:password@ipOfCamera/axis-cgi/mjpg/video.cgi?resolution=640x480&req_fps=30&.mjpg");
if (camera==NULL)
    printf("camera is nulln");
else
    printf("camera is not null");
cvNamedWindow("img");
while (cvWaitKey(10)!=atoi("q")){
    double t1=(double)cvGetTickCount();
    IplImage *img=cvQueryFrame(camera);
    /*if(img){
        cvSaveImage("C:/opencv.jpg",img);
    }*/
    double t2=(double)cvGetTickCount();
    printf("time: %gms  fps: %.2gn",(t2-t1)/(cvGetTickFrequency()*1000.), 1000./((t2-t1)/(cvGetTickFrequency()*1000.)));
    cvShowImage("img",img);
}
cvReleaseCapture(&camera);
}

如果它能帮助像我这样的人,那就太好了。也感谢@karlphillip给你时间。

警告不是错误放松。

在这种情况下,FFmpeg是在抱怨,而不是OpenCV。原因可能是URL上指定的mjpg格式实际上并不需要实际的编解码器。