Class VideoEncoder
Defined in File VideoEncoder.hpp
Inheritance Relationships
Base Type
public dai::NodeCRTP< Node, VideoEncoder, VideoEncoderProperties >(Template Class NodeCRTP)
Class Documentation
-
class VideoEncoder : public dai::NodeCRTP<Node, VideoEncoder, VideoEncoderProperties>
VideoEncoder node. Encodes frames into MJPEG, H264 or H265.
Public Functions
-
void setDefaultProfilePreset(float fps, Properties::Profile profile)
Sets a default preset based on specified frame rate and profile
- Parameters:
fps – Frame rate in frames per second
profile – Encoding profile
-
void setDefaultProfilePreset(int width, int height, float fps, Properties::Profile profile)
Sets a default preset based on specified input size, frame rate and profile
- Parameters:
width – Input frame width
height – Input frame height
fps – Frame rate in frames per second
profile – Encoding profile
-
void 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:
size – Input frame size
fps – Frame rate in frames per second
profile – Encoding profile
-
void setNumFramesPool(int frames)
Set number of frames in pool
- Parameters:
frames – Number of pool frames
-
int getNumFramesPool() const
Get number of frames in pool
- Returns:
Number of pool frames
-
void setRateControlMode(Properties::RateControlMode mode)
Set rate control mode Applicable only to H264 and H265 profiles.
-
void setProfile(Properties::Profile profile)
Set encoding profile.
-
void setProfile(std::tuple<int, int> size, Properties::Profile profile)
Set encoding profile.
-
void setProfile(int width, int height, Properties::Profile profile)
Set encoding profile.
-
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.
-
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.
-
void 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
-
void setNumBFrames(int numBFrames)
Set number of B frames to be inserted. Applicable only to H264 and H265 profiles.
-
void setQuality(int quality)
Set quality for [M]JPEG profile
- Parameters:
quality – Value between 0-100%. Approximates quality
-
void setLossless(bool lossless)
Set lossless mode. Applies only to [M]JPEG profile
- Parameters:
lossless – True to enable lossless jpeg encoding, false otherwise
-
void setFrameRate(float frameRate)
Sets expected frame rate
- Parameters:
frameRate – Frame rate in frames per second
-
void setMaxOutputFrameSize(int maxFrameSize)
Specifies maximum output encoded frame size
-
Properties::RateControlMode getRateControlMode() const
Get rate control mode.
-
Properties::Profile getProfile() const
Get profile.
-
int getBitrate() const
Get bitrate in bps.
-
int getBitrateKbps() const
Get bitrate in kbps.
-
int getKeyframeFrequency() const
Get keyframe frequency.
-
int getNumBFrames() const
Get number of B frames.
-
int getQuality() const
Get quality.
-
std::tuple<int, int> getSize() const
Get input size.
-
int getWidth() const
Get input width.
-
int getHeight() const
Get input height.
-
float getFrameRate() const
Get frame rate.
-
bool getLossless() const
Get lossless mode. Applies only when using [M]JPEG profile.
-
int getMaxOutputFrameSize() const
Public Members
-
Input 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).
-
Output 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.
-
Output 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.
Public Static Attributes
-
static constexpr const char *NAME = "VideoEncoder"
-
void setDefaultProfilePreset(float fps, Properties::Profile profile)