Need to read video in MJPEG format using VideoCapture
I need to read video in MJPG format. I tried the following -
import cv2
cap1 = cv2.VideoCapture(0)
cap1.set(CV_CAP_PROP_FOURCC, ('M', 'J', 'P', 'G'))
It is throwing this error - NameError: name 'CV_CAP_PROP_FOURCC' is not defined
After which I tried -
cap1.set(6, ('M', 'J', 'P', 'G'))
Now, the error is - TypeError: a float is required
How do I capture a video in MJPEG format from the webcam?
and the error is ? also, please show the exact code, you're trying to use
I tried the following. Errors follow -
Code:
cap1 = cv2.VideoCapture(0) cap1.set(CV_FOURCC('M', 'J', 'P', 'G')) cap1.set(3,320) cap1.set(4,240) cap1.set(5,15)
Error: NameError: name 'CV_FOURCC' is not defined
Code: import cv2
cap1 = cv2.VideoCapture(0) cap1.set(CV_CAP_PROP_FOURCC, ('M', 'J', 'P', 'G')) cap1.set(3,320) cap1.set(4,240) cap1.set(5,15)
Error: NameError: name 'CV_CAP_PROP_FOURCC' is not defined
Code: import cv2
cap1 = cv2.VideoCapture(0) cap1.set(6, ('M', 'J', 'P', 'G')) cap1.set(3,320) cap1.set(4,240) cap1.set(5,15)
Error: TypeError: a float is required
please put that code into your question, not a comment.
and the syntax is: capture.set(flag(integer), value(double))
more and more, i think, what you want is not supported at all. (you cannot switch arbitrary webcams to mjpg mode)
WHY do you think, you need this feature ?
I am using Ubuntu 16.04 on Odroid with oCam. Ocamviewer (default viewer of oCam) is streaming with MJPEG. But when I try the same with openCV, I am not successful.
I need to stream videos from two cameras in parallel. If I stream raw, without compression, CPU is used up.