Skip to main content
Version: 🚧 Nightly

Class f3d::video_encoder

Definition: video\_encoder.h (line 25)

Class used to represent a video stream.

A class to represent a video stream, used to encode frames to video packets. It supports a variety of codecs (H264, HEVC, VP8, VP9, AV1) as long as the encoder supports YUV420p pixel format.

Inner classes​

Members​

undefined​

Function getWidth​

virtual int f3d::video_encoder::getWidth() const =0

Get the width and height of the video stream.

Return type: int

Function getHeight​

virtual int f3d::video_encoder::getHeight() const =0

Get the width and height of the video stream.

Return type: int

Public types​

Enumeration type codec​

Definition: video\_encoder.h (line 40)

enum codec {
H264,
HEVC,
VP8,
VP9,
AV1,
EXPLICIT
}

Enumeration of codec types. Supported codecs include H264, HEVC, VP8, VP9, AV1, and EXPLICIT for specifying a codec name. H264 is widely supported and commonly used for video encoding. HEVC (also called H265) offers better compression efficiency than H264 but may have less widespread support. VP8 and VP9 are commonly used for web-based video applications. AV1 is a modern codec with high compression efficiency but may require more computational resources.

Enumerator H264​

Enumerator HEVC​

Enumerator VP8​

Enumerator VP9​

Enumerator AV1​

Enumerator EXPLICIT​

Public functions​

Function ~video_encoder​

virtual f3d::video_encoder::~video_encoder()=default

Return type:

Function listen​

virtual video_encoder & f3d::video_encoder::listen(std::function< void(const std::shared_ptr< video_packet > &)> callback)=0

Asynchronously listen for encoded video packets and invoke the provided callback for each packet. Thread safety is ensured, allowing concurrent calls to submit and listen. Throws transport_exception if there is an error receiving packets from the encoder.

Parameters:

  • std::function< void(const std::shared_ptr< video_packet > &)> callback

Return type: video_encoder &

Function submit​

virtual bool f3d::video_encoder::submit(const std::shared_ptr< video_frame > &frame)=0

Send a frame to the video stream for encoding. Returns true if the frame was successfully submitted, false if the encoder is busy and cannot accept new frames at the moment. Thread safety is ensured, allowing concurrent calls to submit and listen. Throws transport_exception if there is an error submitting the frame to the encoder.

Parameters:

Return type: bool

Function flush​

virtual video_encoder & f3d::video_encoder::flush()=0

Flush the video stream, ensuring all encoded frames are processed. Signals the end of the stream to the encoder, allowing it to output any remaining packets.

Return type: video_encoder &

Public static functions​

Function create​

static std::shared_ptr< video_encoder > f3d::video_encoder::create(const params &p)

Create a video encoder instance. Throws codec_exception if the codec cannot be initialized.

Parameters:

Return type: std::shared_ptr< video_encoder >

Function getAvailableEncoders​

static std::vector< std::pair< std::string, std::string > > f3d::video_encoder::getAvailableEncoders()

Get the list of available codecs.

Return type: std::vector< std::pair< std::string, std::string > >