首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过RTSP流式传输opencv视频

通过RTSP流式传输opencv视频
EN

Stack Overflow用户
提问于 2015-04-05 18:52:04
回答 1查看 3.6K关注 0票数 0

有没有人知道一个链接,在那里我可以捕捉RTSP流来测试rtsp视频源的视频捕获?我已经尝试过usb摄像头和网络摄像头,但我想用RTSP流测试它。

以下是源代码:

代码语言:javascript
复制
#include "opencv2/highgui/highgui.hpp"
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, char* argv[])
{
    VideoCapture cap("rtsp:\\ANYTHING,PLEASE"); // open the video file for reading

    if ( !cap.isOpened() )  // if not success, exit program
    {
         cout << "Cannot open the video file" << endl;
         return -1;
    }

    //cap.set(CV_CAP_PROP_POS_MSEC, 300); //start the video at 300ms

    double fps = cap.get(CV_CAP_PROP_FPS); //get the frames per seconds of the video

     cout << "Frame per seconds : " << fps << endl;

    namedWindow("MyVideo",CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"

    while(1)
    {
        Mat frame;

        bool bSuccess = cap.read(frame); // read a new frame from video

         if (!bSuccess) //if not success, break loop
        {
                        cout << "Cannot read the frame from video file" << endl;
                       break;
        }

        imshow("MyVideo", frame); //show the frame in "MyVideo" window

        if(waitKey(30) == 27) //wait for 'esc' key press for 30 ms. If 'esc' key is pressed, break loop
       {
                cout << "esc key is pressed by user" << endl; 
                break; 
       }
    }

    return 0;

} 
EN

回答 1

Stack Overflow用户

发布于 2015-04-24 21:24:23

使用Videolan VLC可以简单地生成RTSP流。

媒体/流/添加任何视频文件/流/ RTSP添加/端口和路径/视频H.264 + MP3 (MP4) /流。

然后,您将获得类似于rtsp://127.0.0.1:8554/vid的视频流。当然,您可以使用VLC或OpenCV读取该流。

dAAvid

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29456518

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档