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

时间:2013-12-16 14:37:34

标签: c++ opencv video ip-camera

我正在尝试从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编解码器。现在我收到了这个错误。 有人可以告诉我有什么错误。 我已经经历了stackoverflow和opencv的许多帖子,但可以设法得到一个满意的答案。 请帮我。 提前谢谢。

2 个答案:

答案 0 :(得分:5)

我能够使用以下代码解决问题。

#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 null\n");
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: %.2g\n",(t2-t1)/(cvGetTickFrequency()*1000.), 1000./((t2-t1)/(cvGetTickFrequency()*1000.)));
    cvShowImage("img",img);
}
cvReleaseCapture(&camera);
}

如果能帮到像我这样的人,会很好。 还要感谢@karlphillip给你的时间。

答案 1 :(得分:3)

警告不是错误!放松。

在这种情况下,FFmpeg抱怨而不是OpenCV。 The reason is probably because the mjpg format that is specified on the URL doesn't really require an actual codec.