如何使用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
进行流编码吗?如果是,请告诉我。谢谢!