使用OpenCV播放H.264摄像机流

时间:2018-10-26 10:38:21

标签: opencv ffmpeg h.264 opencv3.0

如何使用H.264播放OpenCV个摄像机流?我搜索了一段时间,但没有找到答案。我认为OpenCV可以对h.264的视频进行编码和解码,因为它使用ffmpeg,并且它是VideoWriter类的文档,可确保如以下示例所示:

#include <iostream> // for standard I/O
#include <string>   // for strings

#include <opencv2/core/core.hpp>        // Basic OpenCV structures (cv::Mat)
#include <opencv2/highgui/highgui.hpp>  // Video write

using namespace std;
using namespace cv;

int main()
{
    VideoWriter outputVideo; // For writing the video

    int width = ...; // Declare width here
    int height = ...; // Declare height here
    Size S = Size(width, height); // Declare Size structure

    // Open up the video for writing
    const string filename = ...; // Declare name of file here

    // Declare FourCC code
    int fourcc = CV_FOURCC('H','2','6','4');

    // Declare FPS here
    int fps = ...;
    outputVideo.open(filename, fourcc, fps, S);

    // Put your processing code here
    // ...

    // Logic to write frames here... see below for more details
    // ...

    return 0;
}

OpenCV也可以对h.264进行流编码吗?如果是,请告诉我。谢谢!

0 个答案:

没有答案