[ type ] VideoFormat
Description:
Represents a video format for a VideoDevice. When using this VideoFormat for video input device, make sure that either "pixel_format" or "vcodec" is specified as it was set when you retrieved the supported formats.
Type: Object
Properties:
| Name | Type | Description |
|---|---|---|
|
string | Video frame size in pixels (e.g., "1920x1080"). |
|
number | Minimum available frame rate (e.g., 7.5). (provided when retrieving video input devices) |
|
number | Maximum available frame rate (e.g., 30). (provided when retrieving video input devices) |
|
number | Frame rate in frames per second (required when setting a video input device). |
|
string | Frame image pixel format coming out of the device (e.g., "yuyv422"). If this is present, then |
|
string | Encoded video format that the video device supports (e.g., "mjpeg", "h264"). If this is present, then |
Examples:
Example of a VideoFormat object when retrieved with input devices:
const devices = player.videoInputDevices;
const first_format = devices[0].formats[0];
console.log(first_format); // prints first format of a first device
// outputs something like:
{
size: "1920x1080",
min_fps: 5,
max_fps: 30,
pixel_format: "yuyv422"
}
Setting a video input device:
const devices = player.videoInputDevices;
console.log(devices[0].formats[0]); // prints first format of a first device
const first_format = devices[0].formats[0];
// create new VideoDevice formatted object
const video_device = {
id: devices[0].id,
format: {
size: first_format.size,
fps: first_format.max_fps,
pixel_format: first_format.pixel_format, // set pixel_format in case when it is used instead of vcodec
vcodec: first_format.vcodec // set vcodec in case when it is used instead of pixel format
}
}
// set the video device and start playing
player.setInputDevice(video_device).play();
