How to play H.264
camera streams using OpenCV
? I was searching for a while but i didn't find an answer. I think OpenCV
can encode and decode h.264
videos since it uses ffmpeg
and it is the documentation of the class VideoWriter
ensures that as shown in this example:
#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;
}
So can OpenCV
encode-decode h.264
stream as well? if yes, please let me know how. thanks!!