VideoEncoder node. Encodes frames into MJPEG, H264 or H265. More...
#include <VideoEncoder.hpp>

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< Node > | clone () const override |
| const char * | getName () const override |
Public Member Functions inherited from dai::Node | |
| virtual std::unique_ptr< Node > | clone () const =0 |
| Deep copy the node. More... | |
| AssetManager & | getAssetManager () |
| Get node AssetManager as a reference. More... | |
| const AssetManager & | getAssetManager () 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< Input > | getInputs () |
| 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< Output > | getOutputs () |
| 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 > | |
| Properties & | properties |
| Underlying properties. More... | |
Public Attributes inherited from dai::Node | |
| const Id | id |
| Id of node. More... | |
| Properties & | properties |
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 Properties & | getProperties () |
| virtual tl::optional< OpenVINO::Version > | getRequiredOpenVINOVersion () |
| 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< PipelineImpl > | parent |
| copyable_unique_ptr< Properties > | propertiesHolder |
VideoEncoder node. Encodes frames into MJPEG, H264 or H265.
Definition at line 14 of file VideoEncoder.hpp.
| dai::node::VideoEncoder::VideoEncoder | ( | const std::shared_ptr< PipelineImpl > & | par, |
| int64_t | nodeId | ||
| ) |
Definition at line 13 of file VideoEncoder.cpp.
| 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.
| int dai::node::VideoEncoder::getBitrate | ( | ) | const |
Get bitrate in bps.
Definition at line 93 of file VideoEncoder.cpp.
| int dai::node::VideoEncoder::getBitrateKbps | ( | ) | const |
Get bitrate in kbps.
Definition at line 97 of file VideoEncoder.cpp.
| float dai::node::VideoEncoder::getFrameRate | ( | ) | const |
Get frame rate.
Definition at line 132 of file VideoEncoder.cpp.
| int dai::node::VideoEncoder::getHeight | ( | ) | const |
Get input height.
Definition at line 127 of file VideoEncoder.cpp.
| int dai::node::VideoEncoder::getKeyframeFrequency | ( | ) | const |
Get keyframe frequency.
Definition at line 101 of file VideoEncoder.cpp.
| bool dai::node::VideoEncoder::getLossless | ( | ) | const |
Get lossless mode. Applies only when using [M]JPEG profile.
Definition at line 176 of file VideoEncoder.cpp.
| int dai::node::VideoEncoder::getMaxOutputFrameSize | ( | ) | const |
Definition at line 180 of file VideoEncoder.cpp.
| int dai::node::VideoEncoder::getNumBFrames | ( | ) | const |
Get number of B frames.
Definition at line 109 of file VideoEncoder.cpp.
| int dai::node::VideoEncoder::getNumFramesPool | ( | ) | const |
Get number of frames in pool
Definition at line 27 of file VideoEncoder.cpp.
| VideoEncoderProperties::Profile dai::node::VideoEncoder::getProfile | ( | ) | const |
Get profile.
Definition at line 89 of file VideoEncoder.cpp.
| int dai::node::VideoEncoder::getQuality | ( | ) | const |
Get quality.
Definition at line 113 of file VideoEncoder.cpp.
| VideoEncoderProperties::RateControlMode dai::node::VideoEncoder::getRateControlMode | ( | ) | const |
Get rate control mode.
Definition at line 85 of file VideoEncoder.cpp.
| std::tuple< int, int > dai::node::VideoEncoder::getSize | ( | ) | const |
Get input size.
Definition at line 117 of file VideoEncoder.cpp.
| int dai::node::VideoEncoder::getWidth | ( | ) | const |
Get input width.
Definition at line 122 of file VideoEncoder.cpp.
| 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.
| 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.
| void dai::node::VideoEncoder::setDefaultProfilePreset | ( | float | fps, |
| Properties::Profile | profile | ||
| ) |
Sets a default preset based on specified frame rate and profile
| fps | Frame rate in frames per second |
| profile | Encoding profile |
| 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
| width | Input frame width |
| height | Input frame height |
| fps | Frame rate in frames per second |
| profile | Encoding profile |
| 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
| size | Input frame size |
| fps | Frame rate in frames per second |
| profile | Encoding profile |
| void dai::node::VideoEncoder::setFrameRate | ( | float | frameRate | ) |
Sets expected frame rate
| frameRate | Frame rate in frames per second |
Definition at line 77 of file VideoEncoder.cpp.
| 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:
Definition at line 61 of file VideoEncoder.cpp.
| void dai::node::VideoEncoder::setLossless | ( | bool | lossless | ) |
Set lossless mode. Applies only to [M]JPEG profile
| lossless | True to enable lossless jpeg encoding, false otherwise |
Definition at line 73 of file VideoEncoder.cpp.
| void dai::node::VideoEncoder::setMaxOutputFrameSize | ( | int | maxFrameSize | ) |
Specifies maximum output encoded frame size
Definition at line 81 of file VideoEncoder.cpp.
| 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.
| void dai::node::VideoEncoder::setNumFramesPool | ( | int | frames | ) |
Set number of frames in pool
| frames | Number of pool frames |
Definition at line 21 of file VideoEncoder.cpp.
| void dai::node::VideoEncoder::setProfile | ( | int | width, |
| int | height, | ||
| Properties::Profile | profile | ||
| ) |
Set encoding profile.
| void dai::node::VideoEncoder::setProfile | ( | Properties::Profile | profile | ) |
Set encoding profile.
| void dai::node::VideoEncoder::setProfile | ( | std::tuple< int, int > | size, |
| Properties::Profile | profile | ||
| ) |
Set encoding profile.
| void dai::node::VideoEncoder::setQuality | ( | int | quality | ) |
Set quality for [M]JPEG profile
| quality | Value between 0-100%. Approximates quality |
Definition at line 69 of file VideoEncoder.cpp.
| 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.
| 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 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.
|
staticconstexpr |
Definition at line 16 of file VideoEncoder.hpp.
| 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.