Ask Your Question
0

How to Get MJPEG compression format from webcam!

asked 2013-02-01 21:19:40 -0600

DragonKlavier gravatar image

HI! Im under gentoo linux. I compiled my opencv with all the correct flags to be able to work with this feature...

But when i try to make a:

cvSetCaptureProperty(capture2,CV_CAP_PROP_FOURCC,CV_FOURCC('M','J','P','G')); there was an error:

"Unable to get property <unknown property="" string="">(6) - Invalid argument"

What should I do?

Thaank you!

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
1

answered 2013-02-11 06:48:39 -0600

frank10 gravatar image

updated 2013-02-11 06:51:43 -0600

It's useful to set the Fourcc also in the original stream from the webcam, because if you don't set it to MJPG, it assumes RGB and so at HD res the fps is 5fps. In MJPG instead it goes at 25-30fps!

This code on Windows works:

VideoCapture webcam;
webcam.open(0);
webcam.set(CV_CAP_PROP_FOURCC ,CV_FOURCC('M', 'J', 'P', 'G') );
webcam.set(CV_CAP_PROP_FRAME_WIDTH ,1920);
webcam.set(CV_CAP_PROP_FRAME_HEIGHT ,1080);

The important thing is to set the Fourcc before the width.

edit flag offensive delete link more

Comments

This is what I needed. The fps went from 5fps to 30fps+ for me.

languagelover gravatar imagelanguagelover ( 2017-03-10 13:27:56 -0600 )edit
0

answered 2017-09-08 05:15:20 -0600

Excuse me mates, this topic seems to be related to MJPEG format right? I also have a related question. Recently, I got a video of MJPEG from someone else and it was from a cam i think. I could not open it with our common players like Windows Media Player and VLC. Then, I find a converter in the article (http://www.videoconverterfactory.com/...). But here are the questions. I want to convert this kind of video file to MP4, but I do not know how I can set the video parameters. There are some like bit rate, resolution and frame rate. I want to know whether the higher bit rate and resolution I set, the better output quality it will be? What is the difference between bit rate and resolution? I cannot figure it out by googling. Another question is should I choose MPEG4 or H264 as the output encoder, which one is better?

edit flag offensive delete link more
0

answered 2013-02-02 01:00:57 -0600

sammy gravatar image

updated 2013-02-02 01:01:58 -0600

You don't tell camera to use a specific coding. The CvCapture will decode whatever format the camera is using into IplImage or cv::Mat.

Note that CvCapture will always return decoded images.

The CV_CAP_PROP_FOURCC parameter is for VideoWriter, where you can use it to save a video in MJPG. It doesn't make any sense when you decode a stream, because you cannot change the stream - you area just reading it.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-02-01 21:19:40 -0600

Seen: 33,309 times

Last updated: Feb 11 '13