Flags for video I/O#
Detailed Description#
Enumerations#
enum cv::VideoCaptureAPIs {
cv::CAP_ANY = 0,
cv::CAP_V4L = 200,
cv::CAP_V4L2 = CAP_V4L,
cv::CAP_FIREWIRE = 300,
cv::CAP_FIREWARE = CAP_FIREWIRE,
cv::CAP_IEEE1394 = CAP_FIREWIRE,
cv::CAP_DC1394 = CAP_FIREWIRE,
cv::CAP_CMU1394 = CAP_FIREWIRE,
cv::CAP_DSHOW = 700,
cv::CAP_PVAPI = 800,
cv::CAP_ANDROID = 1000,
cv::CAP_XIAPI = 1100,
cv::CAP_AVFOUNDATION = 1200,
cv::CAP_MSMF = 1400,
cv::CAP_WINRT = 1410,
cv::CAP_INTELPERC = 1500,
cv::CAP_REALSENSE = 1500,
cv::CAP_OPENNI2 = 1600,
cv::CAP_OPENNI2_ASUS = 1610,
cv::CAP_OPENNI2_ASTRA = 1620,
cv::CAP_GPHOTO2 = 1700,
cv::CAP_GSTREAMER = 1800,
cv::CAP_FFMPEG = 1900,
cv::CAP_IMAGES = 2000,
cv::CAP_ARAVIS = 2100,
cv::CAP_OPENCV_MJPEG = 2200,
cv::CAP_INTEL_MFX = 2300,
cv::CAP_XINE = 2400,
cv::CAP_UEYE = 2500,
cv::CAP_OBSENSOR = 2600
}cv::VideoCapture API backends identifier. View details
enum cv::VideoCaptureProperties {
cv::CAP_PROP_UNKNOWN =-1,
cv::CAP_PROP_POS_MSEC =0,
cv::CAP_PROP_POS_FRAMES =1,
cv::CAP_PROP_POS_AVI_RATIO =2,
cv::CAP_PROP_FRAME_WIDTH =3,
cv::CAP_PROP_FRAME_HEIGHT =4,
cv::CAP_PROP_FPS =5,
cv::CAP_PROP_FOURCC =6,
cv::CAP_PROP_FRAME_COUNT =7,
cv::CAP_PROP_FORMAT =8,
cv::CAP_PROP_MODE =9,
cv::CAP_PROP_BRIGHTNESS =10,
cv::CAP_PROP_CONTRAST =11,
cv::CAP_PROP_SATURATION =12,
cv::CAP_PROP_HUE =13,
cv::CAP_PROP_GAIN =14,
cv::CAP_PROP_EXPOSURE =15,
cv::CAP_PROP_CONVERT_RGB =16,
cv::CAP_PROP_WHITE_BALANCE_BLUE_U =17,
cv::CAP_PROP_RECTIFICATION =18,
cv::CAP_PROP_MONOCHROME =19,
cv::CAP_PROP_SHARPNESS =20,
cv::CAP_PROP_AUTO_EXPOSURE =21,
cv::CAP_PROP_GAMMA =22,
cv::CAP_PROP_TEMPERATURE =23,
cv::CAP_PROP_TRIGGER =24,
cv::CAP_PROP_TRIGGER_DELAY =25,
cv::CAP_PROP_WHITE_BALANCE_RED_V =26,
cv::CAP_PROP_ZOOM =27,
cv::CAP_PROP_FOCUS =28,
cv::CAP_PROP_GUID =29,
cv::CAP_PROP_ISO_SPEED =30,
cv::CAP_PROP_BACKLIGHT =32,
cv::CAP_PROP_PAN =33,
cv::CAP_PROP_TILT =34,
cv::CAP_PROP_ROLL =35,
cv::CAP_PROP_IRIS =36,
cv::CAP_PROP_SETTINGS =37,
cv::CAP_PROP_BUFFERSIZE =38,
cv::CAP_PROP_AUTOFOCUS =39,
cv::CAP_PROP_SAR_NUM =40,
cv::CAP_PROP_SAR_DEN =41,
cv::CAP_PROP_BACKEND =42,
cv::CAP_PROP_CHANNEL =43,
cv::CAP_PROP_AUTO_WB =44,
cv::CAP_PROP_WB_TEMPERATURE =45,
cv::CAP_PROP_CODEC_PIXEL_FORMAT =46,
cv::CAP_PROP_BITRATE =47,
cv::CAP_PROP_ORIENTATION_META =48,
cv::CAP_PROP_ORIENTATION_AUTO =49,
cv::CAP_PROP_HW_ACCELERATION =50,
cv::CAP_PROP_HW_DEVICE =51,
cv::CAP_PROP_HW_ACCELERATION_USE_OPENCL =52,
cv::CAP_PROP_OPEN_TIMEOUT_MSEC =53,
cv::CAP_PROP_READ_TIMEOUT_MSEC =54,
cv::CAP_PROP_STREAM_OPEN_TIME_USEC =55,
cv::CAP_PROP_VIDEO_TOTAL_CHANNELS = 56,
cv::CAP_PROP_VIDEO_STREAM = 57,
cv::CAP_PROP_AUDIO_STREAM = 58,
cv::CAP_PROP_AUDIO_POS = 59,
cv::CAP_PROP_AUDIO_SHIFT_NSEC = 60,
cv::CAP_PROP_AUDIO_DATA_DEPTH = 61,
cv::CAP_PROP_AUDIO_SAMPLES_PER_SECOND = 62,
cv::CAP_PROP_AUDIO_BASE_INDEX = 63,
cv::CAP_PROP_AUDIO_TOTAL_CHANNELS = 64,
cv::CAP_PROP_AUDIO_TOTAL_STREAMS = 65,
cv::CAP_PROP_AUDIO_SYNCHRONIZE = 66,
cv::CAP_PROP_LRF_HAS_KEY_FRAME = 67,
cv::CAP_PROP_CODEC_EXTRADATA_INDEX = 68,
cv::CAP_PROP_FRAME_TYPE = 69,
cv::CAP_PROP_N_THREADS = 70,
cv::CAP_PROP_PTS = 71,
cv::CAP_PROP_DTS_DELAY = 72,
cv::CAP_PROP_IMAGE_SEQ_START = 73
}cv::VideoCapture generic properties identifier. View details
enum cv::VideoWriterProperties {
cv::VIDEOWRITER_PROP_UNKNOWN = -1,
cv::VIDEOWRITER_PROP_QUALITY = 1,
cv::VIDEOWRITER_PROP_FRAMEBYTES = 2,
cv::VIDEOWRITER_PROP_NSTRIPES = 3,
cv::VIDEOWRITER_PROP_IS_COLOR = 4,
cv::VIDEOWRITER_PROP_DEPTH = 5,
cv::VIDEOWRITER_PROP_HW_ACCELERATION = 6,
cv::VIDEOWRITER_PROP_HW_DEVICE = 7,
cv::VIDEOWRITER_PROP_HW_ACCELERATION_USE_OPENCL = 8,
cv::VIDEOWRITER_PROP_RAW_VIDEO = 9,
cv::VIDEOWRITER_PROP_KEY_INTERVAL = 10,
cv::VIDEOWRITER_PROP_KEY_FLAG = 11,
cv::VIDEOWRITER_PROP_PTS = 12,
cv::VIDEOWRITER_PROP_DTS_DELAY = 13,
cv::VIDEOWRITER_PROP_COLOR_SPACE = 14,
cv::VIDEOWRITER_PROP_ENABLE_ALPHA = 15
}cv::VideoWriter generic properties identifier. View details
Enumeration Type Documentation#
VideoCaptureAPIs#
enum cv::VideoCaptureAPIs
#include <opencv2/videoio.hpp>
cv::VideoCapture API backends identifier.
Select preferred API for a capture object. To be used in the VideoCapture::VideoCapture() constructor or VideoCapture::open()
Note
Backends are available only if they have been built with your OpenCV binaries. See videoio_overview for more information.
Microsoft Media Foundation backend tries to use hardware accelerated transformations if possible. Environment flag “OPENCV_VIDEOIO_MSMF_ENABLE_HW_TRANSFORMS” set to 0 disables it and may improve initialization time. More details: https://learn.microsoft.com/en-us/windows/win32/medfound/mf-readwrite-enable-hardware-transforms
Enumerator:
|
Auto detect == 0. |
|
V4L/V4L2 capturing support. |
|
Same as CAP_V4L. |
|
IEEE 1394 drivers. |
|
Same value as CAP_FIREWIRE. |
|
Same value as CAP_FIREWIRE. |
|
Same value as CAP_FIREWIRE. |
|
Same value as CAP_FIREWIRE. |
|
DirectShow (via videoInput) |
|
PvAPI, Prosilica GigE SDK. |
|
MediaNDK (API Level 21+) and NDK Camera (API level 24+) for Android. |
|
XIMEA Camera API. |
|
AVFoundation framework for iOS (OS X Lion will have the same API) |
|
Microsoft Media Foundation (via videoInput). See platform specific notes above. |
|
Microsoft Windows Runtime using Media Foundation. |
|
RealSense (former Intel Perceptual Computing SDK) |
|
Synonym for CAP_INTELPERC. |
|
OpenNI2 (for Kinect) |
|
OpenNI2 (for Asus Xtion and Occipital Structure sensors) |
|
OpenNI2 (for Orbbec Astra) |
|
gPhoto2 connection |
|
GStreamer. |
|
Open and record video file or stream using the FFMPEG library. |
|
OpenCV Image Sequence (e.g. img_%02d.jpg) |
|
Aravis SDK. |
|
Built-in OpenCV MotionJPEG codec. |
|
Intel MediaSDK. |
|
XINE engine (Linux) |
|
uEye Camera API |
|
For Orbbec 3D-Sensor device/module (Astra+, Femto, Astra2, Gemini2, Gemini2L, Gemini2XL, Gemini330, Femto Mega) attention: Astra2 cameras currently only support Windows and Linux kernel versions no higher than 4.15, and higher versions of Linux kernel may have exceptions. |
VideoCaptureProperties#
enum cv::VideoCaptureProperties
#include <opencv2/videoio.hpp>
cv::VideoCapture generic properties identifier.
Reading / writing properties involves many layers. Some unexpected result might happens along this chain. Effective behaviour depends from device hardware, driver and API Backend.
See also
Additional flags for video I/O API backends, VideoCapture::get(), VideoCapture::set()
Enumerator:
|
Returned by VideoCapture::get if the requested property is unknown or unsupported. |
|
Current position of the video file in milliseconds. |
|
0-based index of the frame to be decoded/captured next. When the index i is set in RAW mode (CAP_PROP_FORMAT == -1) this will seek to the key frame k, where k <= i. |
|
Relative position of the video file: 0=start of the film, 1=end of the film. |
|
Width of the frames in the video stream. |
|
Height of the frames in the video stream. |
|
Frame rate. |
|
4-character code of codec. see VideoWriter::fourcc . |
|
Number of frames in the video file. |
|
Format of the Mat objects (see Mat::type()) returned by VideoCapture::retrieve(). Set value -1 to fetch undecoded RAW video streams (as Mat 8UC1). Default is 8UC3. FFmpeg backend supports 8UC4 with alpha, if it’s available. |
|
Backend-specific value indicating the current capture mode. |
|
Brightness of the image (only for those cameras that support). |
|
Contrast of the image (only for cameras). |
|
Saturation of the image (only for cameras). |
|
Hue of the image (only for cameras). |
|
Gain of the image (only for those cameras that support). |
|
Exposure (only for those cameras that support). |
|
Boolean flags indicating whether images should be converted to BGR. GStreamer note: The flag is ignored in case if custom pipeline is used. It’s user responsibility to interpret pipeline output. |
|
Currently unsupported. |
|
Rectification flag for stereo cameras (note: only supported by DC1394 v 2.x backend currently). |
|
|
|
|
|
DC1394: exposure control done by camera, user can adjust reference level using this feature. |
|
|
|
|
|
|
|
|
|
|
|
Android: May switch physical cameras/lenses. Factor and range are hardware-dependent. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Pop up video/camera filter dialog (note: only supported by DSHOW backend currently. The property value is ignored) |
|
|
|
|
|
Sample aspect ratio: num/den (num) |
|
Sample aspect ratio: num/den (den) |
|
Current backend (enum VideoCaptureAPIs). Read-only property. |
|
Video input or Channel Number (only for those cameras that support) |
|
enable/ disable auto white-balance |
|
white-balance color temperature |
|
(read-only) codec’s pixel format. 4-character code - see VideoWriter::fourcc . Subset of AV_PIX_FMT_* or -1 if unknown |
|
(read-only) Video bitrate in kbits/s |
|
(read-only) Frame rotation defined by stream meta (applicable for FFmpeg and AVFoundation back-ends only) |
|
if true - rotates output frames of CvCapture considering video file’s metadata (applicable for FFmpeg and AVFoundation back-ends only) (opencv/opencv#15499) |
|
(open-only) Hardware acceleration type (see VideoAccelerationType). Setting supported only via |
|
(open-only) Hardware device index (select GPU if multiple available). Device enumeration is acceleration type specific. |
|
(open-only) If non-zero, create new OpenCL context and bind it to current thread. The OpenCL context created with Video Acceleration context attached it (if not attached yet) for optimized GPU data copy between HW accelerated decoder and cv::UMat. |
|
(open-only) timeout in milliseconds for opening a video capture (applicable for FFmpeg and GStreamer back-ends only) |
|
(open-only) timeout in milliseconds for reading from a video capture (applicable for FFmpeg and GStreamer back-ends only) |
|
(read-only) time in microseconds since Jan 1 1970 when stream was opened. Applicable for FFmpeg backend only. Useful for RTSP and other live streams |
|
(read-only) Number of video channels |
|
(open-only) Specify video stream, 0-based index. Use -1 to disable video stream from file or IP cameras. Default value is 0. |
|
(open-only) Specify stream in multi-language media files, -1 - disable audio processing or microphone. Default value is -1. |
|
(read-only) Audio position is measured in samples. Accurate audio sample timestamp of previous grabbed fragment. See CAP_PROP_AUDIO_SAMPLES_PER_SECOND and CAP_PROP_AUDIO_SHIFT_NSEC. |
|
(read only) Contains the time difference between the start of the audio stream and the video stream in nanoseconds. Positive value means that audio is started after the first video frame. Negative value means that audio is started before the first video frame. |
|
(open, read) Alternative definition to bits-per-sample, but with clear handling of 32F / 32S |
|
(open, read) determined from file/codec input. If not specified, then selected audio sample rate is 44100 |
|
(read-only) Index of the first audio channel for .retrieve() calls. That audio channel number continues enumeration after video channels. |
|
(read-only) Number of audio channels in the selected audio stream (mono, stereo, etc) |
|
(read-only) Number of audio streams. |
|
(open, read) Enables audio synchronization. |
|
FFmpeg back-end only - Indicates whether the Last Raw Frame (LRF), output from VideoCapture::read() when VideoCapture is initialized with VideoCapture::open(CAP_FFMPEG, {CAP_PROP_FORMAT, -1}) or VideoCapture::set(CAP_PROP_FORMAT,-1) is called before the first call to VideoCapture::read(), contains encoded data for a key frame. |
|
Positive index indicates that returning extra data is supported by the video back end. This can be retrieved as cap.retrieve(data, |
|
(read-only) FFmpeg back-end only - Frame type ascii code (73 = ‘I’, 80 = ‘P’, 66 = ‘B’ or 63 = ‘?’ if unknown) of the most recently read frame. |
|
(open-only) Set the maximum number of threads to use. Use 0 to use as many threads as CPU cores (applicable for FFmpeg back-end only). |
|
(read-only) FFmpeg back-end only - presentation timestamp of the most recently read frame using the FPS time base. e.g. fps = 25, VideoCapture::get(CAP_PROP_PTS) = 3, presentation time = 3/25 seconds. |
|
(read-only) FFmpeg back-end only - maximum difference between presentation (pts) and decompression timestamps (dts) using FPS time base. e.g. delay is maximum when frame_num = 0, if true, VideoCapture::get(CAP_PROP_PTS) = 0 and VideoCapture::get(CAP_PROP_DTS_DELAY) = 2, dts = -2. Non zero values usually imply the stream is encoded using B-frames which are not decoded in presentation order. |
|
(open-only) Start number for image sequences opened with a printf-style pattern (e.g. |
VideoWriterProperties#
enum cv::VideoWriterProperties
#include <opencv2/videoio.hpp>
cv::VideoWriter generic properties identifier.
See also
Enumerator:
|
Returned by VideoWriter::get if the requested property is unknown or unsupported. |
|
Current quality (0..100%) of the encoded videostream. Can be adjusted dynamically in some codecs. |
|
(Read-only): Size of just encoded video frame. Note that the encoding order may be different from representation order. |
|
Number of stripes for parallel encoding. -1 for auto detection. |
|
If it is not zero, the encoder will expect and encode color frames, otherwise it will work with grayscale frames. |
|
Defaults to CV_8U. |
|
(open-only) Hardware acceleration type (see VideoAccelerationType). Setting supported only via |
|
(open-only) Hardware device index (select GPU if multiple available). Device enumeration is acceleration type specific. |
|
(open-only) If non-zero, create new OpenCL context and bind it to current thread. The OpenCL context created with Video Acceleration context attached it (if not attached yet) for optimized GPU data copy between cv::UMat and HW accelerated encoder. |
|
(open-only) Set to non-zero to enable encapsulation of an encoded raw video stream. Each raw encoded video frame should be passed to VideoWriter::write() as single row or column of a CV_8UC1 Mat. Note If the key frame interval is not 1 then it must be manually specified by the user. This can either be performed during initialization passing VIDEOWRITER_PROP_KEY_INTERVAL as one of the extra encoder params to VideoWriter::VideoWriter(const String &, int, double, const Size &, const std::vector< int > ¶ms) or afterwards by setting the VIDEOWRITER_PROP_KEY_FLAG with VideoWriter::set() before writing each frame. FFMpeg backend only. |
|
(open-only) Set the key frame interval using raw video encapsulation (VIDEOWRITER_PROP_RAW_VIDEO != 0). Defaults to 1 when not set. FFmpeg back-end only. |
|
Set to non-zero to signal that the following frames are key frames or zero if not, when encapsulating raw video (VIDEOWRITER_PROP_RAW_VIDEO != 0). FFmpeg back-end only. |
|
Specifies the frame presentation timestamp for each frame using the FPS time base. This property is only necessary when encapsulating externally encoded video where the decoding order differs from the presentation order, such as in GOP patterns with bi-directional B-frames. The value should be provided by your external encoder and for video sources with fixed frame rates it is equivalent to dividing the current frame’s presentation time (CAP_PROP_POS_MSEC) by the frame duration (1000.0 / VideoCapture::get(CAP_PROP_FPS)). It can be queried from the resulting encapsulated video file using VideoCapture::get(CAP_PROP_PTS). FFmpeg back-end only. |
|
Specifies the maximum difference between presentation (pts) and decompression timestamps (dts) using the FPS time base. This property is necessary only when encapsulating externally encoded video where the decoding order differs from the presentation order, such as in GOP patterns with bi-directional B-frames. The value should be calculated based on the specific GOP pattern used during encoding. For example, in a GOP with presentation order IBP and decoding order IPB, this value would be 1, as the B-frame is the second frame presented but the third to be decoded. It can be queried from the resulting encapsulated video file using VideoCapture::get(CAP_PROP_DTS_DELAY). Non-zero values usually imply the stream is encoded using B-frames. FFmpeg back-end only. |
|
(open-only) GStreamer backend only. Pixel format for the encoding profile. Default is “I420”. Other values: “NV12”, “BGRx”. See GStreamer raw video formats for more options. |
|
(open-only) FFmpeg backend only. Defines that input frames contain alpha channel. |