Public Member Functions | Public Attributes | Static Public Attributes | List of all members
dai::node::VideoEncoder Class Reference

VideoEncoder node. Encodes frames into MJPEG, H264 or H265. More...

#include <VideoEncoder.hpp>

Inheritance diagram for dai::node::VideoEncoder:
Inheritance graph
[legend]

Public Member Functions

int getBitrate () const
 Get bitrate in bps. More...
 
int getBitrateKbps () const
 Get bitrate in kbps. More...
 
float getFrameRate () const
 Get frame rate. More...
 
int getHeight () const
 Get input height. More...
 
int getKeyframeFrequency () const
 Get keyframe frequency. More...
 
bool getLossless () const
 Get lossless mode. Applies only when using [M]JPEG profile. More...
 
int getMaxOutputFrameSize () const
 
int getNumBFrames () const
 Get number of B frames. More...
 
int getNumFramesPool () const
 
Properties::Profile getProfile () const
 Get profile. More...
 
int getQuality () const
 Get quality. More...
 
Properties::RateControlMode getRateControlMode () const
 Get rate control mode. More...
 
std::tuple< int, int > getSize () const
 Get input size. More...
 
int getWidth () const
 Get input width. More...
 
void setBitrate (int bitrate)
 Set output bitrate in bps, for CBR rate control mode. 0 for auto (based on frame size and FPS). Applicable only to H264 and H265 profiles. More...
 
void setBitrateKbps (int bitrateKbps)
 Set output bitrate in kbps, for CBR rate control mode. 0 for auto (based on frame size and FPS). Applicable only to H264 and H265 profiles. More...
 
void setDefaultProfilePreset (float fps, Properties::Profile profile)
 
void setDefaultProfilePreset (int width, int height, float fps, Properties::Profile profile)
 
void setDefaultProfilePreset (std::tuple< int, int > size, float fps, Properties::Profile profile)
 
void setFrameRate (float frameRate)
 
void setKeyframeFrequency (int freq)
 
void setLossless (bool lossless)
 
void setMaxOutputFrameSize (int maxFrameSize)
 
void setNumBFrames (int numBFrames)
 Set number of B frames to be inserted. Applicable only to H264 and H265 profiles. More...
 
void setNumFramesPool (int frames)
 
void setProfile (int width, int height, Properties::Profile profile)
 Set encoding profile. More...
 
void setProfile (Properties::Profile profile)
 Set encoding profile. More...
 
void setProfile (std::tuple< int, int > size, Properties::Profile profile)
 Set encoding profile. More...
 
void setQuality (int quality)
 
void setRateControlMode (Properties::RateControlMode mode)
 Set rate control mode Applicable only to H264 and H265 profiles. More...
 
 VideoEncoder (const std::shared_ptr< PipelineImpl > &par, int64_t nodeId)
 
 VideoEncoder (const std::shared_ptr< PipelineImpl > &par, int64_t nodeId, std::unique_ptr< Properties > props)
 
- Public Member Functions inherited from dai::NodeCRTP< Node, VideoEncoder, VideoEncoderProperties >
std::unique_ptr< Nodeclone () const override
 
const char * getName () const override
 
- Public Member Functions inherited from dai::Node
virtual std::unique_ptr< Nodeclone () const =0
 Deep copy the node. More...
 
AssetManagergetAssetManager ()
 Get node AssetManager as a reference. More...
 
const AssetManagergetAssetManager () const
 Get node AssetManager as a const reference. More...
 
std::vector< Input * > getInputRefs ()
 Retrieves reference to node inputs. More...
 
std::vector< const Input * > getInputRefs () const
 Retrieves reference to node inputs. More...
 
std::vector< InputgetInputs ()
 Retrieves all nodes inputs. More...
 
virtual const char * getName () const =0
 Retrieves nodes name. More...
 
std::vector< Output * > getOutputRefs ()
 Retrieves reference to node outputs. More...
 
std::vector< const Output * > getOutputRefs () const
 Retrieves reference to node outputs. More...
 
std::vector< OutputgetOutputs ()
 Retrieves all nodes outputs. More...
 
Pipeline getParentPipeline ()
 
const Pipeline getParentPipeline () const
 
 Node (const std::shared_ptr< PipelineImpl > &p, Id nodeId, std::unique_ptr< Properties > props)
 Constructs Node. More...
 
virtual ~Node ()=default
 

Public Attributes

Output bitstream {*this, "bitstream", Output::Type::MSender, {{DatatypeEnum::ImgFrame, false}}}
 
Input input {*this, "in", Input::Type::SReceiver, true, 4, true, {{DatatypeEnum::ImgFrame, true}}}
 
Output out {*this, "out", Output::Type::MSender, {{DatatypeEnum::EncodedFrame, false}}}
 
- Public Attributes inherited from dai::NodeCRTP< Node, VideoEncoder, VideoEncoderProperties >
Propertiesproperties
 Underlying properties. More...
 
- Public Attributes inherited from dai::Node
const Id id
 Id of node. More...
 
Propertiesproperties
 

Static Public Attributes

constexpr static const char * NAME = "VideoEncoder"
 

Additional Inherited Members

- Public Types inherited from dai::NodeCRTP< Node, VideoEncoder, VideoEncoderProperties >
using Properties = VideoEncoderProperties
 
- Public Types inherited from dai::Node
using Id = std::int64_t
 Node identificator. Unique for every node on a single Pipeline. More...
 
- Protected Member Functions inherited from dai::Node
virtual PropertiesgetProperties ()
 
virtual tl::optional< OpenVINO::VersiongetRequiredOpenVINOVersion ()
 
void setInputMapRefs (InputMap *inMapRef)
 
void setInputMapRefs (std::initializer_list< InputMap * > l)
 
void setInputRefs (Input *inRef)
 
void setInputRefs (std::initializer_list< Input * > l)
 
void setOutputMapRefs (OutputMap *outMapRef)
 
void setOutputMapRefs (std::initializer_list< OutputMap * > l)
 
void setOutputRefs (Output *outRef)
 
void setOutputRefs (std::initializer_list< Output * > l)
 
- Protected Attributes inherited from dai::Node
AssetManager assetManager
 
std::unordered_map< std::string, InputMap * > inputMapRefs
 
std::unordered_map< std::string, Input * > inputRefs
 
std::unordered_map< std::string, OutputMap * > outputMapRefs
 
std::unordered_map< std::string, Output * > outputRefs
 
std::weak_ptr< PipelineImplparent
 
copyable_unique_ptr< PropertiespropertiesHolder
 

Detailed Description

VideoEncoder node. Encodes frames into MJPEG, H264 or H265.

Definition at line 14 of file VideoEncoder.hpp.

Constructor & Destructor Documentation

◆ VideoEncoder() [1/2]

dai::node::VideoEncoder::VideoEncoder ( const std::shared_ptr< PipelineImpl > &  par,
int64_t  nodeId 
)

Definition at line 13 of file VideoEncoder.cpp.

◆ VideoEncoder() [2/2]

dai::node::VideoEncoder::VideoEncoder ( const std::shared_ptr< PipelineImpl > &  par,
int64_t  nodeId,
std::unique_ptr< Properties props 
)

Definition at line 15 of file VideoEncoder.cpp.

Member Function Documentation

◆ getBitrate()

int dai::node::VideoEncoder::getBitrate ( ) const

Get bitrate in bps.

Definition at line 93 of file VideoEncoder.cpp.

◆ getBitrateKbps()

int dai::node::VideoEncoder::getBitrateKbps ( ) const

Get bitrate in kbps.

Definition at line 97 of file VideoEncoder.cpp.

◆ getFrameRate()

float dai::node::VideoEncoder::getFrameRate ( ) const

Get frame rate.

Definition at line 132 of file VideoEncoder.cpp.

◆ getHeight()

int dai::node::VideoEncoder::getHeight ( ) const

Get input height.

Definition at line 127 of file VideoEncoder.cpp.

◆ getKeyframeFrequency()

int dai::node::VideoEncoder::getKeyframeFrequency ( ) const

Get keyframe frequency.

Definition at line 101 of file VideoEncoder.cpp.

◆ getLossless()

bool dai::node::VideoEncoder::getLossless ( ) const

Get lossless mode. Applies only when using [M]JPEG profile.

Definition at line 176 of file VideoEncoder.cpp.

◆ getMaxOutputFrameSize()

int dai::node::VideoEncoder::getMaxOutputFrameSize ( ) const

Definition at line 180 of file VideoEncoder.cpp.

◆ getNumBFrames()

int dai::node::VideoEncoder::getNumBFrames ( ) const

Get number of B frames.

Definition at line 109 of file VideoEncoder.cpp.

◆ getNumFramesPool()

int dai::node::VideoEncoder::getNumFramesPool ( ) const

Get number of frames in pool

Returns
Number of pool frames

Definition at line 27 of file VideoEncoder.cpp.

◆ getProfile()

VideoEncoderProperties::Profile dai::node::VideoEncoder::getProfile ( ) const

Get profile.

Definition at line 89 of file VideoEncoder.cpp.

◆ getQuality()

int dai::node::VideoEncoder::getQuality ( ) const

Get quality.

Definition at line 113 of file VideoEncoder.cpp.

◆ getRateControlMode()

VideoEncoderProperties::RateControlMode dai::node::VideoEncoder::getRateControlMode ( ) const

Get rate control mode.

Definition at line 85 of file VideoEncoder.cpp.

◆ getSize()

std::tuple< int, int > dai::node::VideoEncoder::getSize ( ) const

Get input size.

Definition at line 117 of file VideoEncoder.cpp.

◆ getWidth()

int dai::node::VideoEncoder::getWidth ( ) const

Get input width.

Definition at line 122 of file VideoEncoder.cpp.

◆ setBitrate()

void dai::node::VideoEncoder::setBitrate ( int  bitrate)

Set output bitrate in bps, for CBR rate control mode. 0 for auto (based on frame size and FPS). Applicable only to H264 and H265 profiles.

Definition at line 53 of file VideoEncoder.cpp.

◆ setBitrateKbps()

void dai::node::VideoEncoder::setBitrateKbps ( int  bitrateKbps)

Set output bitrate in kbps, for CBR rate control mode. 0 for auto (based on frame size and FPS). Applicable only to H264 and H265 profiles.

Definition at line 57 of file VideoEncoder.cpp.

◆ setDefaultProfilePreset() [1/3]

void dai::node::VideoEncoder::setDefaultProfilePreset ( float  fps,
Properties::Profile  profile 
)

Sets a default preset based on specified frame rate and profile

Parameters
fpsFrame rate in frames per second
profileEncoding profile

◆ setDefaultProfilePreset() [2/3]

void dai::node::VideoEncoder::setDefaultProfilePreset ( int  width,
int  height,
float  fps,
Properties::Profile  profile 
)

Sets a default preset based on specified input size, frame rate and profile

Parameters
widthInput frame width
heightInput frame height
fpsFrame rate in frames per second
profileEncoding profile

◆ setDefaultProfilePreset() [3/3]

void dai::node::VideoEncoder::setDefaultProfilePreset ( std::tuple< int, int >  size,
float  fps,
Properties::Profile  profile 
)

Sets a default preset based on specified input size, frame rate and profile

Parameters
sizeInput frame size
fpsFrame rate in frames per second
profileEncoding profile

◆ setFrameRate()

void dai::node::VideoEncoder::setFrameRate ( float  frameRate)

Sets expected frame rate

Parameters
frameRateFrame rate in frames per second

Definition at line 77 of file VideoEncoder.cpp.

◆ setKeyframeFrequency()

void dai::node::VideoEncoder::setKeyframeFrequency ( int  freq)

Set keyframe frequency. Every Nth frame a keyframe is inserted.

Applicable only to H264 and H265 profiles

Examples:

  • 30 FPS video, keyframe frequency: 30. Every 1s a keyframe will be inserted
  • 60 FPS video, keyframe frequency: 180. Every 3s a keyframe will be inserted

Definition at line 61 of file VideoEncoder.cpp.

◆ setLossless()

void dai::node::VideoEncoder::setLossless ( bool  lossless)

Set lossless mode. Applies only to [M]JPEG profile

Parameters
losslessTrue to enable lossless jpeg encoding, false otherwise

Definition at line 73 of file VideoEncoder.cpp.

◆ setMaxOutputFrameSize()

void dai::node::VideoEncoder::setMaxOutputFrameSize ( int  maxFrameSize)

Specifies maximum output encoded frame size

Definition at line 81 of file VideoEncoder.cpp.

◆ setNumBFrames()

void dai::node::VideoEncoder::setNumBFrames ( int  numBFrames)

Set number of B frames to be inserted. Applicable only to H264 and H265 profiles.

Definition at line 65 of file VideoEncoder.cpp.

◆ setNumFramesPool()

void dai::node::VideoEncoder::setNumFramesPool ( int  frames)

Set number of frames in pool

Parameters
framesNumber of pool frames

Definition at line 21 of file VideoEncoder.cpp.

◆ setProfile() [1/3]

void dai::node::VideoEncoder::setProfile ( int  width,
int  height,
Properties::Profile  profile 
)

Set encoding profile.

◆ setProfile() [2/3]

void dai::node::VideoEncoder::setProfile ( Properties::Profile  profile)

Set encoding profile.

◆ setProfile() [3/3]

void dai::node::VideoEncoder::setProfile ( std::tuple< int, int >  size,
Properties::Profile  profile 
)

Set encoding profile.

◆ setQuality()

void dai::node::VideoEncoder::setQuality ( int  quality)

Set quality for [M]JPEG profile

Parameters
qualityValue between 0-100%. Approximates quality

Definition at line 69 of file VideoEncoder.cpp.

◆ setRateControlMode()

void dai::node::VideoEncoder::setRateControlMode ( Properties::RateControlMode  mode)

Set rate control mode Applicable only to H264 and H265 profiles.

Definition at line 32 of file VideoEncoder.cpp.

Member Data Documentation

◆ bitstream

Output dai::node::VideoEncoder::bitstream {*this, "bitstream", Output::Type::MSender, {{DatatypeEnum::ImgFrame, false}}}

Outputs ImgFrame message that carries BITSTREAM encoded (MJPEG, H264 or H265) frame data. Mutually exclusive with out.

Definition at line 30 of file VideoEncoder.hpp.

◆ input

Input dai::node::VideoEncoder::input {*this, "in", Input::Type::SReceiver, true, 4, true, {{DatatypeEnum::ImgFrame, true}}}

Input for NV12 ImgFrame to be encoded Default queue is blocking with size set by 'setNumFramesPool' (4).

Definition at line 25 of file VideoEncoder.hpp.

◆ NAME

constexpr static const char* dai::node::VideoEncoder::NAME = "VideoEncoder"
staticconstexpr

Definition at line 16 of file VideoEncoder.hpp.

◆ out

Output dai::node::VideoEncoder::out {*this, "out", Output::Type::MSender, {{DatatypeEnum::EncodedFrame, false}}}

Outputs EncodedFrame message that carries encoded (MJPEG, H264 or H265) frame data. Mutually exclusive with bitstream.

Definition at line 35 of file VideoEncoder.hpp.


The documentation for this class was generated from the following files:


depthai
Author(s): Martin Peterlin
autogenerated on Sat Mar 22 2025 02:58:20