Jetson Inference
DNN Vision Library
videoOptions Struct Reference

The videoOptions struct contains common settings that are used to configure and query videoSource and videoOutput streams. More...

#include <videoOptions.h>

Public Types

enum  DeviceType {
  DEVICE_DEFAULT = 0, DEVICE_V4L2, DEVICE_CSI, DEVICE_IP,
  DEVICE_FILE, DEVICE_DISPLAY
}
 Device interface types. More...
 
enum  IoType { INPUT = 0, OUTPUT }
 Input/Output stream type. More...
 
enum  FlipMethod {
  FLIP_NONE = 0, FLIP_COUNTERCLOCKWISE, FLIP_ROTATE_180, FLIP_CLOCKWISE,
  FLIP_HORIZONTAL, FLIP_UPPER_RIGHT_DIAGONAL, FLIP_VERTICAL, FLIP_UPPER_LEFT_DIAGONAL,
  FLIP_DEFAULT = FLIP_NONE
}
 Settings of the flip method used by MIPI CSI cameras and compressed video inputs. More...
 
enum  Codec {
  CODEC_UNKNOWN = 0, CODEC_RAW, CODEC_H264, CODEC_H265,
  CODEC_VP8, CODEC_VP9, CODEC_MPEG2, CODEC_MPEG4,
  CODEC_MJPEG
}
 Video codecs. More...
 
enum  CodecType {
  CODEC_CPU = 0, CODEC_OMX, CODEC_V4L2, CODEC_NVENC,
  CODEC_NVDEC
}
 Video codec engines. More...
 

Public Member Functions

 videoOptions ()
 Constructor using default options. More...
 
void Print (const char *prefix=NULL) const
 Log the video settings, with an optional prefix label. More...
 
bool Parse (const char *URI, const int argc, char **argv, IoType ioType, const char *extraFlag=NULL)
 
bool Parse (const char *URI, const commandLine &cmdLine, IoType ioType)
 
bool Parse (const int argc, char **argv, IoType ioType, int ioPositionArg=-1)
 
bool Parse (const commandLine &cmdLine, IoType ioType, int ioPositionArg=-1)
 

Static Public Member Functions

static const char * IoTypeToStr (IoType type)
 Convert an IoType enum to a string. More...
 
static IoType IoTypeFromStr (const char *str)
 Parse an IoType enum from a string. More...
 
static const char * DeviceTypeToStr (DeviceType type)
 Convert a DeviceType enum to a string. More...
 
static DeviceType DeviceTypeFromStr (const char *str)
 Parse a DeviceType enum from a string. More...
 
static const char * FlipMethodToStr (FlipMethod flip)
 Convert a FlipMethod enum to a string. More...
 
static FlipMethod FlipMethodFromStr (const char *str)
 Parse a FlipMethod enum from a string. More...
 
static const char * CodecToStr (Codec codec)
 Convert a Codec enum to a string. More...
 
static Codec CodecFromStr (const char *str)
 Parse a Codec enum from a string. More...
 
static const char * CodecTypeToStr (CodecType codecType)
 Convert a CodecType enum to a string. More...
 
static CodecType CodecTypeFromStr (const char *str)
 Parse a Codec enum from a string. More...
 

Public Attributes

URI resource
 The resource URI of the device, IP stream, or file/directory. More...
 
URI save
 Optional path to save the compressed stream to a video file on disk, which is to be used in addition to the primary resource URI above. More...
 
uint32_t width
 The width of the stream (in pixels). More...
 
uint32_t height
 The height of the stream (in pixels). More...
 
float frameRate
 The framerate of the stream (the default is 30Hz). More...
 
uint64_t frameCount
 The number of frames that have been captured or output on this interface. More...
 
uint32_t bitRate
 The encoding bitrate for compressed streams (only applies to video codecs like H264/H265). More...
 
uint32_t numBuffers
 The number of ring buffers used for threading. More...
 
bool zeroCopy
 If true, indicates the buffers are allocated in zeroCopy memory that is mapped to both the CPU and GPU. More...
 
int loop
 Control the number of loops for videoSource disk-based inputs (for example, the number of times that a video should loop). More...
 
int latency
 Number of milliseconds of video to buffer for network RTSP or WebRTC streams. More...
 
DeviceType deviceType
 Indicates the type of device interface used by this stream. More...
 
IoType ioType
 Indicates if this stream is an input or an output. More...
 
FlipMethod flipMethod
 The flip method controls if and how an input frame is flipped/rotated in pre-processing from a MIPI CSI camera or compressed video input. More...
 
Codec codec
 Indicates the codec used by the stream. More...
 
CodecType codecType
 Indicates the underlying hardware/software engine used by the codec. More...
 
std::string stunServer
 URL of STUN server used for WebRTC. More...
 
std::string sslCert
 Path to a file containing a PEM-encoded SSL/TLS certificate. More...
 
std::string sslKey
 Path to a file containing a PEM-encoded private key. More...
 

Detailed Description

The videoOptions struct contains common settings that are used to configure and query videoSource and videoOutput streams.

Member Enumeration Documentation

◆ Codec

Video codecs.

Enumerator
CODEC_UNKNOWN 

Unknown/unsupported codec.

CODEC_RAW 

Uncompressed (e.g.

RGB)

CODEC_H264 

H.264.

CODEC_H265 

H.265.

CODEC_VP8 

VP8.

CODEC_VP9 

VP9.

CODEC_MPEG2 

MPEG2 (decode only)

CODEC_MPEG4 

MPEG4 (decode only)

CODEC_MJPEG 

MJPEG.

◆ CodecType

Video codec engines.

Enumerator
CODEC_CPU 

CPU-based implementation using libav (e.g.

avdec_h264 / x264enc)

CODEC_OMX 

aarch64 & JetPack 4 only - OMX hardware plugins (e.g.

omxh264dec/omxh264enc)

CODEC_V4L2 

aarch64 & JetPack 5 only - V4L2 hardware plugins (e.g.

nvv4l2decoder/nvv4l2h264enc)

CODEC_NVENC 

x86 only - NVENC hardware plugin (not currently implemented)

CODEC_NVDEC 

x86 only - NVDEC hardware plugin (not currently implemented)

◆ DeviceType

Device interface types.

Enumerator
DEVICE_DEFAULT 

Unknown interface type.

DEVICE_V4L2 

V4L2 webcam (e.g.

/dev/video0)

DEVICE_CSI 

MIPI CSI camera.

DEVICE_IP 

IP-based network stream (e.g.

RTP/RTSP)

DEVICE_FILE 

Disk-based stream from a file or directory of files.

DEVICE_DISPLAY 

OpenGL output stream rendered to an attached display.

◆ FlipMethod

Settings of the flip method used by MIPI CSI cameras and compressed video inputs.

Enumerator
FLIP_NONE 

Identity (no rotation)

FLIP_COUNTERCLOCKWISE 

Rotate counter-clockwise 90 degrees.

FLIP_ROTATE_180 

Rotate 180 degrees.

FLIP_CLOCKWISE 

Rotate clockwise 90 degrees.

FLIP_HORIZONTAL 

Flip horizontally.

FLIP_UPPER_RIGHT_DIAGONAL 

Flip across upper right/lower left diagonal.

FLIP_VERTICAL 

Flip vertically.

FLIP_UPPER_LEFT_DIAGONAL 

Flip across upper left/lower right diagonal.

FLIP_DEFAULT 

Default setting (none)

◆ IoType

Input/Output stream type.

Enumerator
INPUT 

Input stream (e.g.

camera, video/image file, ect.)

OUTPUT 

Output stream (e.g.

display, video/image file, ect.)

Constructor & Destructor Documentation

◆ videoOptions()

videoOptions::videoOptions ( )

Constructor using default options.

Member Function Documentation

◆ CodecFromStr()

static Codec videoOptions::CodecFromStr ( const char *  str)
static

Parse a Codec enum from a string.

◆ CodecToStr()

static const char* videoOptions::CodecToStr ( Codec  codec)
static

Convert a Codec enum to a string.

◆ CodecTypeFromStr()

static CodecType videoOptions::CodecTypeFromStr ( const char *  str)
static

Parse a Codec enum from a string.

◆ CodecTypeToStr()

static const char* videoOptions::CodecTypeToStr ( CodecType  codecType)
static

Convert a CodecType enum to a string.

◆ DeviceTypeFromStr()

static DeviceType videoOptions::DeviceTypeFromStr ( const char *  str)
static

Parse a DeviceType enum from a string.

◆ DeviceTypeToStr()

static const char* videoOptions::DeviceTypeToStr ( DeviceType  type)
static

Convert a DeviceType enum to a string.

◆ FlipMethodFromStr()

static FlipMethod videoOptions::FlipMethodFromStr ( const char *  str)
static

Parse a FlipMethod enum from a string.

◆ FlipMethodToStr()

static const char* videoOptions::FlipMethodToStr ( FlipMethod  flip)
static

Convert a FlipMethod enum to a string.

◆ IoTypeFromStr()

static IoType videoOptions::IoTypeFromStr ( const char *  str)
static

Parse an IoType enum from a string.

◆ IoTypeToStr()

static const char* videoOptions::IoTypeToStr ( IoType  type)
static

Convert an IoType enum to a string.

◆ Parse() [1/4]

bool videoOptions::Parse ( const char *  URI,
const commandLine cmdLine,
IoType  ioType 
)

◆ Parse() [2/4]

bool videoOptions::Parse ( const char *  URI,
const int  argc,
char **  argv,
IoType  ioType,
const char *  extraFlag = NULL 
)

◆ Parse() [3/4]

bool videoOptions::Parse ( const commandLine cmdLine,
IoType  ioType,
int  ioPositionArg = -1 
)

◆ Parse() [4/4]

bool videoOptions::Parse ( const int  argc,
char **  argv,
IoType  ioType,
int  ioPositionArg = -1 
)

◆ Print()

void videoOptions::Print ( const char *  prefix = NULL) const

Log the video settings, with an optional prefix label.

Member Data Documentation

◆ bitRate

uint32_t videoOptions::bitRate

The encoding bitrate for compressed streams (only applies to video codecs like H264/H265).

For videoOutput streams, this option can be set from the command line using --bitrate=N.

Note
the default bitrate for encoding output streams is 4Mbps (target VBR).

◆ codec

Codec videoOptions::codec

Indicates the codec used by the stream.

This is only really applicable to compressed streams, otherwise it will be CODEC_RAW.

videoSource input streams will attempt to discover the codec type (i.e. from video file), however RTP streams need this to be explitly set using the --input-codec=xyz option (where xyz is a string like h264, h265, vp8, vp9, mpeg2, mpeg4, or mjpeg).

A compressed videoOutput stream will default to H.264 encoding, but can be set using the --output-codec=xyz command line option (same values for xyz as above).

◆ codecType

CodecType videoOptions::codecType

Indicates the underlying hardware/software engine used by the codec.

For input streams, this can be set with --decode=cpu or --decode=v4l2 for example. For output streams, this can be set with --encode=cpu or --encode=v4l2 for example. The default setting is to use hardware-acceleration on Jetson (aarch64) and CPU on x86.

◆ deviceType

DeviceType videoOptions::deviceType

Indicates the type of device interface used by this stream.

◆ flipMethod

FlipMethod videoOptions::flipMethod

The flip method controls if and how an input frame is flipped/rotated in pre-processing from a MIPI CSI camera or compressed video input.

Other types of streams will ignore this.

This option can be set from the command line using --flip-method=xyz, where xyz is one of the strings below:

  • none (Identity, no rotation)
  • counterclockwise (Rotate counter-clockwise 90 degrees)
  • rotate-180 (Rotate 180 degrees)
  • clockwise (Rotate clockwise 90 degrees)
  • horizontal-flip (Flip horizontally)
  • vertical-flip (Flip vertically)
  • upper-right-diagonal (Flip across upper right/lower left diagonal)
  • upper-left-diagonal (Flip across upper left/lower right diagonal)

◆ frameCount

uint64_t videoOptions::frameCount

The number of frames that have been captured or output on this interface.

◆ frameRate

float videoOptions::frameRate

The framerate of the stream (the default is 30Hz).

This option can be set from the command line using --input-rate=N or --output-rate=N for input and output streams, respectively. The --framerate=N option sets it for both.

◆ height

uint32_t videoOptions::height

The height of the stream (in pixels).

This option can be set from the command line using --input-height=N for videoSource streams, or --output-height=N for videoOutput streams.

◆ ioType

IoType videoOptions::ioType

Indicates if this stream is an input or an output.

◆ latency

int videoOptions::latency

Number of milliseconds of video to buffer for network RTSP or WebRTC streams.

The default setting is 10ms (which is lower than GStreamer's default settings). If you have connection/buffering problems, try increasing the latency setting. It can be set from the command line using --input-latency=N or --output-latency=N

◆ loop

int videoOptions::loop

Control the number of loops for videoSource disk-based inputs (for example, the number of times that a video should loop).

Other types of streams will ignore it.

The following values are are valid:

-1 = loop forever 0 = don't loop >0 = set number of loops

This option can be set from the command line using --loop=N.

Note
by default, looping is disabled (set to 0).

◆ numBuffers

uint32_t videoOptions::numBuffers

The number of ring buffers used for threading.

This option can be set from the command line using --num-buffers=N.

Note
the default number of ring buffers is 4.

◆ resource

URI videoOptions::resource

The resource URI of the device, IP stream, or file/directory.

See also
URI for details about accepted protocols and URI formats.

◆ save

URI videoOptions::save

Optional path to save the compressed stream to a video file on disk, which is to be used in addition to the primary resource URI above.

This option can be set from the command-line using --input-save for videoSource streams, or --output-save for videoOutput streams.

◆ sslCert

std::string videoOptions::sslCert

Path to a file containing a PEM-encoded SSL/TLS certificate.

This is used for enabling HTTPS in the WebRTC server. It can be set from the command-line using the --ssl-cert or --https-cert options. You can make your own self-signed certificate by running a command like: openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365

◆ sslKey

std::string videoOptions::sslKey

Path to a file containing a PEM-encoded private key.

This is used for enabling HTTPS in the WebRTC server. It can be set from the command-line using the --ssl-key or --https-key options. You can make your own self-signed certificate by running a command like: openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365

◆ stunServer

std::string videoOptions::stunServer

URL of STUN server used for WebRTC.

This can be set using the --stun-server command-line argument. STUN servers are used during ICE/NAT and allow a local device to determine its public IP address. If this is left blank and WebRTC is used, then a default STUN server will be assigned.

◆ width

uint32_t videoOptions::width

The width of the stream (in pixels).

This option can be set from the command line using --input-width=N for videoSource streams, or --output-width=N for videoOutput streams.

◆ zeroCopy

bool videoOptions::zeroCopy

If true, indicates the buffers are allocated in zeroCopy memory that is mapped to both the CPU and GPU.

Otherwise, the buffers are only accessible from the GPU.

Note
the default is true (zeroCopy CPU/GPU access enabled).

The documentation for this struct was generated from the following file: