arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | List of all members
VideoEncoder Class Referenceabstract

Common interface for video encoders (e.g. H264Encoder, H264EncoderESP32S3 - CodecH264.h/CodecH264ESP32S3.h) - standardizes lifecycle (begin()/end()), the Print target the encoded bitstream is written to, the raw-picture input format (setVideoFormat()), and a single write() that encodes one picture in that format and writes the result to setOutput()'s target - one write() call per picture, mirroring VideoOutput's write()-per-frame convention on the decoder side. Concrete encoders may still expose their own additional config knobs (e.g. bitrate/QP) beyond this shared surface. More...

#include <CodecVideo.h>

Inheritance diagram for VideoEncoder:
H264Encoder H264EncoderESP32S3< Alloc > MPGEncoder

Public Member Functions

virtual ~VideoEncoder ()=default
 
virtual bool begin ()=0
 Initializes the encoder (allocates its picture buffers, etc).
 
virtual void end ()=0
 Releases the encoder's resources.
 
virtual void setOutput (Print &out)=0
 Defines the target the encoded bitstream is written to.
 
virtual void setVideoFormat (VideoFormat format)=0
 
virtual VideoInfo videoInfo ()=0
 
virtual size_t write (const uint8_t *data, size_t len)=0
 

Detailed Description

Common interface for video encoders (e.g. H264Encoder, H264EncoderESP32S3 - CodecH264.h/CodecH264ESP32S3.h) - standardizes lifecycle (begin()/end()), the Print target the encoded bitstream is written to, the raw-picture input format (setVideoFormat()), and a single write() that encodes one picture in that format and writes the result to setOutput()'s target - one write() call per picture, mirroring VideoOutput's write()-per-frame convention on the decoder side. Concrete encoders may still expose their own additional config knobs (e.g. bitrate/QP) beyond this shared surface.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ ~VideoEncoder()

virtual ~VideoEncoder ( )
virtualdefault

Member Function Documentation

◆ begin()

virtual bool begin ( )
pure virtual

Initializes the encoder (allocates its picture buffers, etc).

Implemented in H264Encoder, H264EncoderESP32S3< Alloc >, and MPGEncoder.

◆ end()

virtual void end ( )
pure virtual

Releases the encoder's resources.

Implemented in H264Encoder, H264EncoderESP32S3< Alloc >, and MPGEncoder.

◆ setOutput()

virtual void setOutput ( Print out)
pure virtual

Defines the target the encoded bitstream is written to.

Implemented in H264Encoder, H264EncoderESP32S3< Alloc >, and MPGEncoder.

◆ setVideoFormat()

virtual void setVideoFormat ( VideoFormat  format)
pure virtual

Selects the raw picture format write() expects - e.g. VideoFormat::I420 (planar Y/U/V, concatenated in one buffer), YUV422 (packed YUYV), RGB565/RGB666/RGB888 (packed). Not every encoder backend supports every value - unsupported values are logged and ignored (the previously selected format stays in effect); see the concrete class for exactly which ones it supports. Call before the first write().

Implemented in H264Encoder, H264EncoderESP32S3< Alloc >, and MPGEncoder.

◆ videoInfo()

virtual VideoInfo videoInfo ( )
pure virtual

Reports the format/dimensions of the bitstream written to setOutput()'s target - VideoInfo::format is the actual encoded codec (e.g. VideoFormat::H264), NOT setVideoFormat()'s raw input format, the reliable way to determine it (rather than assuming); width/height match the encoder's configured picture size (e.g. setSize()), 0 if that was never called.

Implemented in H264Encoder, H264EncoderESP32S3< Alloc >, and MPGEncoder.

◆ write()

virtual size_t write ( const uint8_t *  data,
size_t  len 
)
pure virtual

Encodes one raw picture (in setVideoFormat()'s format, sized for the encoder's configured width/height) and writes the result to setOutput()'s target, returning the number of bytes written (0 if nothing was, e.g. setOutput()/size wasn't configured, or the format is unsupported).

Implemented in H264Encoder, H264EncoderESP32S3< Alloc >, and MPGEncoder.


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