Ask Your Question
0

Use mjpeg compression

asked 2012-12-16 13:33:44 -0600

dinamex gravatar image

updated 2012-12-17 08:11:30 -0600

Hi all,

I would like to use the mjpeg compression of my webcam (logitech c920). I can see with $v4l2-ctl --list-formats that MJPEG is supported:

Output:

ioctl: VIDIOC_ENUM_FMT
Index       : 0
Type        : Video Capture
Pixel Format: 'YUYV'
Name        : YUV 4:2:2 (YUYV)

Index       : 1
Type        : Video Capture
Pixel Format: '' (compressed)
Name        : 34363248-0000-0010-8000-00aa003

Index       : 2
Type        : Video Capture
Pixel Format: 'MJPG' (compressed)
Name        : MJPEG

But I tried different ways to set the compression in my code but it doesn't work.

I tried:

cap.set(CV_CAP_PROP_FOURCC, 'M', 'J', 'P', 'G');

which leeds to the outputs that there are to many parameters. Therefore I changed to second parameter like this.

cap.set(CV_CAP_PROP_FOURCC, 2);

This leads to following output:

HIGHGUI ERROR: V4L: Property <unknown property string>(6) not supported by device
HIGHGUI ERROR: V4L2: Unable to get property <unknown property string>(6) - Invalid argument

Would be great to get your help. I appreciate any suggestions.

edit retag flag offensive close merge delete

Comments

2

I'm having the same problem, did you find a solution?

randomlogic78 gravatar imagerandomlogic78 ( 2013-01-11 11:32:49 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-06-27 10:05:32 -0600

Djerom gravatar image

Hi, You can try this command :

cap.set(cv::CAP_PROP_FOURCC, cv::VideoWriter::fourcc('M', 'J', 'P', 'G'));

It should work.

edit flag offensive delete link more

Comments

1

@Djerom I hope dinamex don't wait an answer since 2012

LBerger gravatar imageLBerger ( 2018-06-27 11:33:26 -0600 )edit

Question Tools

Stats

Asked: 2012-12-16 13:33:44 -0600

Seen: 2,651 times

Last updated: Dec 17 '12