|
arduino-audio-tools
|
H.264 video encoder for ESP32-S3: wraps esp_h264::H264Encoder (https://github.com/pschatzmann/ESP32S3-h264) - the ESP32-S3-specific counterpart of H264Encoder (CodecH264.h, the portable TinyH264-based encoder). Configure via setSize()/setFrameRate()/setBitrate()/ setGop()/setQpRange()/setVideoFormat() (I420 - the default -, RGB565 or YUV422), then feed raw pictures via write() - it writes the resulting Annex-B bitstream straight to the Print target passed to setOutput() (the underlying esp_h264::H264Encoder methods already take a Print& and handle the write, retrying on partial writes - see H264Encoder.h's encode()). More...
#include <CodecH264ESP32S3.h>


Classes | |
| class | DualOutputPrint |
Public Member Functions | |
| H264EncoderESP32S3 () | |
| H264EncoderESP32S3 (Print &out) | |
| H264EncoderESP32S3 (VideoOutput &out) | |
| bool | begin () override |
| Initializes the encoder - see esp_h264::H264Encoder::begin(). | |
| esp_h264::H264Encoder< Alloc > & | driver () |
| void | end () override |
| Releases the encoder's resources - see esp_h264::H264Encoder::end(). | |
| void | setBitrate (int bitsPerSecond) |
| void | setFrameRate (int fps) |
| void | setGop (int gop) |
| void | setOutput (Print &out) override |
| void | setOutput (VideoOutput &out) |
| void | setOutputBufferSize (size_t size) |
| void | setQpRange (int qpMin, int qpMax) |
| void | setSize (int width, int height) |
| void | setVideoFormat (VideoFormat format) override |
| VideoInfo | videoInfo () override |
| size_t | write (const uint8_t *data, size_t len) override |
Protected Attributes | |
| esp_h264::H264Encoder< Alloc >::Config | config_ |
| DualOutputPrint | dual_out_ |
| esp_h264::H264Encoder< Alloc > | encoder_ |
| VideoFormat | input_format = VideoFormat::I420 |
| Print * | p_out = nullptr |
| VideoOutput * | p_out_video = nullptr |
H.264 video encoder for ESP32-S3: wraps esp_h264::H264Encoder (https://github.com/pschatzmann/ESP32S3-h264) - the ESP32-S3-specific counterpart of H264Encoder (CodecH264.h, the portable TinyH264-based encoder). Configure via setSize()/setFrameRate()/setBitrate()/ setGop()/setQpRange()/setVideoFormat() (I420 - the default -, RGB565 or YUV422), then feed raw pictures via write() - it writes the resulting Annex-B bitstream straight to the Print target passed to setOutput() (the underlying esp_h264::H264Encoder methods already take a Print& and handle the write, retrying on partial writes - see H264Encoder.h's encode()).
Unlike esp_h264::H264Encoder itself, this wrapper does not drive an attached camera (its use_camera/pin/captureH264() surface) - it only covers the encode-a-buffer-you-already-have path, matching H264Encoder's (CodecH264.h) scope; use esp_h264::H264Encoder directly (via driver()) if you want its built-in camera capture loop instead.
The Alloc template parameter is forwarded to esp_h264::H264Encoder - see that class's own file comment (H264Encoder.h) for the PSRAM- vs. internal-RAM allocator choice (H264EncoderPSRAM/H264EncoderRAM aliases). Defaults to H264_DEFAULT_ALLOCATOR.
|
inline |
|
inline |
|
inline |
|
inlineoverridevirtual |
Initializes the encoder - see esp_h264::H264Encoder::begin().
Implements VideoEncoder.
|
inline |
Direct access to the wrapped esp_h264::H264Encoder, e.g. for its camera-capture surface (begin() with use_camera/pin fields set, captureH264()) - not exposed through this wrapper.
|
inlineoverridevirtual |
Releases the encoder's resources - see esp_h264::H264Encoder::end().
Implements VideoEncoder.
|
inline |
Target bitrate (bits/sec) - defaults to width*height*fps*30/100 if never called. Call before begin().
|
inline |
|
inline |
Group-of-Pictures size (keyframe interval, in frames) - defaults to setFrameRate()'s fps if never called. Call before begin().
|
inlineoverridevirtual |
Defines the target each write() call writes its encoded bitstream to.
Implements VideoEncoder.
|
inline |
|
inline |
Output buffer size (bytes) the wrapped encoder allocates for the encoded bitstream - defaults to one uncompressed I420 frame's worth if never called. Call before begin().
Quantizer parameter range [0, 51] the encoder's rate control stays within - lower is better quality/higher bitrate. Defaults to [28, 30] if never called. Call before begin().
|
inlineoverridevirtual |
Selects the raw picture format write() expects - this backend (esp_h264) supports VideoFormat::I420 (the default: planar Y/U/V, no row padding), RGB565 (16-bit, 5-6-5 packed, little-endian) and YUV422 (packed YUYV); any other value is logged and ignored (the previously selected format stays in effect). Call before the first write().
Implements VideoEncoder.
|
inlineoverridevirtual |
Reports the codec/dimensions of the bitstream written to setOutput()'s target - format is always VideoFormat::H264 (NOT setVideoFormat()'s raw input format); width/height match setSize() (0 if that was never called).
Implements VideoEncoder.
|
inlineoverridevirtual |
Encodes one raw picture, in setVideoFormat()'s format (I420 by default: Y, then U, then V, no row padding; RGB565 - converted internally to I420 - or YUV422, likewise), and writes the result to setOutput() - len must be at least width*height*3/2 (I420) or width*height*2 (RGB565/YUV422). Returns the number of bytes written on success (see class comment - not an exact byte count, the underlying esp_h264::H264Encoder only reports success/failure), or 0 on failure (e.g. setOutput() wasn't configured, len too small, or the format is unsupported).
Implements VideoEncoder.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |