I have a camera from e-con systems that supports video recording of the UYVU codec. When I use my own software (QTCam) to record video, it is recorded in avi format with YUY2 Codec, which video opens and works fine in VLC.

Now I tried to record video through Opencv VideoWrtiter (). I used this command to set the Camera property to read the UYVY Codec video image.
camera1.set(CV_CAP_PROP_FOURCC,CV_FOURCC('U','Y','V','Y'));
and use VideoWriter to record video in AVI format.
video1.open("/home/camera1UYVY.avi",CV_FOURCC('Y','U','Y','2'),30,s1,true);
The power from the camera works, I checked with imshow (). But the recorded video does not play in VLC, as it works for recording recorded with QTCam.
Even the recorded recorded opencv has the same codec

My code is below
#include <opencv2/core/core.hpp> #include <opencv2/video/video.hpp> #include <opencv2/imgcodecs/imgcodecs.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/videoio/videoio.hpp> #include <iostream> using namespace std; using namespace cv; int main(int argc, char **argv) { VideoCapture camera1; Mat frame1; camera1.open(0); camera1.set(CV_CAP_PROP_FOURCC,CV_FOURCC('U','Y','V','Y')); camera1.set(CV_CAP_PROP_FRAME_WIDTH,1280); camera1.set(CV_CAP_PROP_FRAME_HEIGHT,720); cout << "FPS:" << camera1.get(CV_CAP_PROP_FPS) << endl; camera1.set(CV_CAP_PROP_FPS,30); cout << "FPS:" << camera1.get(CV_CAP_PROP_FPS) << endl; cout << "Camera -1 Codec: " << (int)camera1.get(CV_CAP_PROP_FOURCC) << endl; VideoWriter video1; cout << camera1.get(CV_CAP_PROP_FRAME_WIDTH) << endl; cout << camera1.get(CV_CAP_PROP_FRAME_HEIGHT) << endl; Size s1 = Size((int)camera1.get(CV_CAP_PROP_FRAME_WIDTH),(int)camera1.get(CV_CAP_PROP_FRAME_HEIGHT)); video1.open("/home/camera1UYVY.avi",CV_FOURCC('Y','U','Y','2'),30,s1,true); while(!camera1.isOpened()){ cout << "Camera not opened" << endl; continue; } while(1){ if(!video1.isOpened()){ cout << "Error opening video" << endl; } camera1.read(frame1); imshow("Display1",frame1); video1.write(frame1); cout << frame1.data << endl; if(waitKey(1) == 27){ break; } } video1.release(); camera1.release(); return 0;
} please tell me where I'm going. I want to record an uncompressed video from the camera and save it as a video file (which opens in VLC or any other player)