RTc流在Opencv中失败

时间:2015-07-06 06:02:24

标签: c++ opencv ffmpeg rtsp ip-camera

我尝试使用OpenCV 2.4.8从IP-camera读取RTSP h.264流:

#include <opencv2/opencv.hpp>
int main()
{
    cv::VideoCapture capture("rtsp://admin:@192.168.1.168:80/ch0_0.264");

    if(!capture.isOpened())
    {
        std::cout << "Error opening video stream" << std::endl;
        return -1;
    }

    cv::Mat frame;
    cv::namedWindow("Frame");

    int i = 0;
    while (true)
    {
        if(capture.read(frame))
        {
            std::cout << ++i << std::endl;
            cv::imshow("Frame", frame);
            if (cv::waitKey(1) >= 0)
                break;
        }
        else
        {
            std::cout << "No frame" << std::endl;
        }
    }
}

首先捕获了670-700帧(流的25-30秒),但是进一步capture.read(frame)总是返回false(未抓取的帧)。如何解决这个问题?

0 个答案:

没有答案