|
arduino-audio-tools
|
Configuration for the (single) video track written by MuxerAVI. More...
#include <ContainerAVI.h>
Public Member Functions | |
| MuxerAVI () | |
| MuxerAVI (Print &out) | |
| size_t | addAudioFrame (const uint8_t *data, size_t len) override |
| size_t | addI420Frame (const uint8_t *data, size_t len) override |
| size_t | addJpegFrame (const uint8_t *data, size_t len) override |
| size_t | addRGB565Frame (const uint8_t *data, size_t len) override |
| size_t | addVideoFrame (const uint8_t *data, size_t len, bool isKeyFrame=true) override |
| size_t | addYUV422Frame (const uint8_t *data, size_t len) override |
| uint32_t | audioChunkCount () |
| Number of audio chunks written so far. | |
| AudioInfoFormat & | audioInfo () override |
| Provides read/write access to the audio track's AudioInfoFormat. | |
| bool | begin () override |
| void | beginFrame (size_t size) |
| void | end () override |
| Closes the encoder: no trailer is written (streaming AVI has no idx1) | |
| uint32_t | endFrame () |
| Closes the current video frame (word-aligns the chunk) | |
| virtual void | flush () |
| float | getAudioSamplesPerVideoFrame () |
| MuxerVideoConfig | getVideoInfo () override |
| const char * | mime () override |
| operator bool () override | |
| void | setAudioInfo (AudioInfoFormat info) override |
| void | setOutput (Print &out) override |
| Defines the output: e.g. a local File or a network Client. | |
| void | setStreamType (StreamContentType type) override |
| void | setVideoInfo (MuxerVideoConfig config) override |
| Defines the video track configuration - call before begin() | |
| StreamContentType | streamType () override |
| The track write() currently targets (see setStreamType()) | |
| uint32_t | videoFrameCount () |
| Number of video frames written so far. | |
| size_t | write (const uint8_t *data, size_t len) override |
| size_t | writeFrame (const uint8_t *data, size_t len) |
Protected Member Functions | |
| uint32_t | audioStrlSize () |
| uint16_t | biBitCount () |
| uint32_t | biSizeImage () |
| void | checkRawFrame (VideoFormat expected, size_t len) |
| void | checkVideoFormat (VideoFormat expected) |
| size_t | expectedRawFrameSize (VideoFormat format) |
| const char * | fourCC () |
| bool | isBitfields () |
| uint32_t | videoStrfSize () |
| uint32_t | videoStrlSize () |
| void | writeAudioStrl () |
| void | writeBiCompression () |
| void | writeChunkHeader (const char *id, uint32_t size) |
| void | writeFourCC (const char *cc) |
| void | writeHeader () |
| void | writeI16 (int16_t v) |
| void | writeMainHeader () |
| void | writeU16 (uint16_t v) |
| void | writeU32 (uint32_t v) |
| void | writeU8 (uint8_t v) |
| void | writeVideoStrl () |
| void | writeZeros (int n) |
Protected Attributes | |
| uint32_t | audio_chunk_count = 0 |
| AudioInfoFormat | audio_info |
| bool | frame_open = false |
| bool | frame_pad = false |
| size_t | frame_remaining = 0 |
| bool | has_audio = false |
| bool | is_open = false |
| Print * | p_out = nullptr |
| Print * | p_print = nullptr |
| MuxerVideoConfig | video_cfg |
| uint32_t | video_frame_count = 0 |
| StreamContentType | write_stream_type = StreamContentType::Video |
Static Protected Attributes | |
| static const uint32_t | AVIF_ISINTERLEAVED = 0x00000100 |
Configuration for the (single) video track written by MuxerAVI.
AVI Container Encoder: muxes an already-encoded video stream (e.g. H.264 access units) and an optional PCM/compressed audio stream into a RIFF/AVI container written to a Print (a local File to record, or e.g. a network Client to publish a live stream to an HTTP/TCP client).
This is a streaming writer: since the total number of frames/bytes is usually not known upfront, the RIFF/movi sizes and stream dwLength fields are written as "unknown" (0xFFFFFFFF) and no idx1 index is appended - the same technique used by live IP-camera AVI/MJPEG streams. This is sufficient for sequential playback (ffplay/VLC/mpv opening the stream, or a file written for later playback) but the result is not seekable. All structural sizes a parser needs while walking the file sequentially (avih/strh/strf chunk sizes, hdrl LIST size) are written exactly.
Usage:
|
inline |
|
inlineoverridevirtual |
Writes one interleaved audio block as a single '01wb' chunk. Ignored (returns 0) if no audio track was configured via setAudioInfo().
Implements Muxer.
|
inlineoverridevirtual |
Writes one planar 4:2:0 YUV (I420/IYUV) frame: a full-resolution Y plane followed by quarter-resolution U and V planes. Expects exactly width*height*3/2 bytes.
Implements Muxer.
|
inlineoverridevirtual |
Writes one complete Motion-JPEG frame: a full, already-encoded JPEG image (e.g. as produced by an ESP32-CAM or other hardware JPEG encoder). Length is inherently variable, so only the configured format is validated, not the size.
Implements Muxer.
|
inlineoverridevirtual |
Writes one uncompressed RGB565 (16-bit, 5-6-5) frame. Expects exactly width*height*2 bytes.
Implements Muxer.
|
inlineoverridevirtual |
Convenience: writes one complete, already-encoded video frame (e.g. one H.264 access unit, or one raw pixel buffer) as a single '00dc' chunk. Works for any VideoFormat - the format-specific addXxxFrame() methods below are thin wrappers that additionally validate the format and (for fixed-size raw formats) the buffer length.
| isKeyFrame | accepted for interface compatibility with Muxer::addVideoFrame() - AVI has no per-frame sync-sample flag to write it into, so it is ignored. |
Implements Muxer.
|
inlineoverridevirtual |
Writes one packed 4:2:2 YUV frame (YUY2/YUYV byte order). Expects exactly width*height*2 bytes.
Implements Muxer.
|
inline |
Number of audio chunks written so far.
|
inlineoverridevirtual |
Provides read/write access to the audio track's AudioInfoFormat.
Implements Muxer.
|
inlineprotected |
Bytes following the audio strl LIST's own size field (only valid if has_audio)
|
inlineoverridevirtual |
Writes the RIFF/AVI header. Call after configuring video (and audio, if any) and before writing any frames.
Implements Muxer.
|
inline |
Starts a new video ('00dc') chunk of the given size. This is MuxerAVI's own API for incremental frame construction (not part of the VideoOutput interface - RIFF chunks are length-prefixed, so the size must be known upfront, unlike the write()/flush() contract VideoOutput consumers use).
|
inlineprotected |
Bits per pixel written into biBitCount; purely informational for compressed formats
|
inlineprotected |
biSizeImage: the uncompressed buffer size for raw formats, 0 (unknown/ variable) for compressed ones
|
inlineprotected |
Validates both the configured format and (for fixed-size raw formats) that len matches width*height based expectations
|
inlineprotected |
Logs a warning if getVideoInfo().format was not set to the format that an addXxxFrame() convenience method was called for
|
inlineoverridevirtual |
Closes the encoder: no trailer is written (streaming AVI has no idx1)
Implements Muxer.
|
inline |
Closes the current video frame (word-aligns the chunk)
|
inlineprotected |
Number of raw bytes a single frame must have for the given (uncompressed, fixed-size) format; 0 for compressed/variable-size formats where this check does not apply
|
inlinevirtualinherited |
Finalizes the frame most recently written via one or more write() calls - see class comment. Default no-op for implementations that display/decode synchronously in write() instead.
Reimplemented from VideoOutput.
|
inlineprotected |
|
inlineinherited |
Average number of audio samples per video frame, derived from audioInfo().sample_rate and getVideoInfo().fps - the natural audio chunk size to write once per video frame if you want to keep both tracks advancing at roughly the same pace as you write them (not a hard requirement - see addAudioFrame()/addVideoFrame()). 0 if fps hasn't been set.
|
inlineoverridevirtual |
Provides the video track configuration, analogous to DemuxerAVI's getVideoInfo() getter.
Implements Muxer.
|
inlineprotected |
True if this format is written as uncompressed RGB565 using BI_BITFIELDS (which needs 3 extra DWORD color masks in 'strf')
|
inlineoverridevirtual |
The container's MIME type (e.g. "video/avi", "video/mp4") - useful for e.g. an HTTP Content-Type header when streaming the muxed output to a client.
Implements Muxer.
|
inlineoverridevirtual |
Implements Muxer.
|
inlineoverridevirtual |
Adds an (optional) interleaved audio track. 'info.format' selects the WAVEFORMATEX tag written for the audio track (default: AudioFormat::PCM). Only uncompressed PCM has been validated for playback in common players; other tags are written through as-is. Call before begin().
Implements Muxer.
|
inlineoverridevirtual |
|
inlineoverridevirtual |
Selects whether write() feeds the video or the audio track. Defaults to StreamContentType::Video; switch to StreamContentType::Audio (and back) around calls when using MuxerAVI as a plain sink for both.
Implements Muxer.
|
inlineoverridevirtual |
|
inlineoverridevirtual |
The track write() currently targets (see setStreamType())
Implements Muxer.
|
inline |
Number of video frames written so far.
|
inlineprotected |
Size of the 'strf' chunk payload: the base 40-byte BITMAPINFOHEADER, plus 3 extra DWORD color masks for BI_BITFIELDS formats (RGB565)
|
inlineprotected |
Bytes following the video strl LIST's own size field: the "strl" list-type FOURCC plus the nested strh/strf chunks (each incl. header)
|
inlineoverridevirtual |
VideoOutput API / generic sink: writes one complete frame to whichever track streamType() currently selects (see setStreamType()). For video, dispatches to the addXxxFrame() matching getVideoInfo().format; for audio, calls addAudioFrame(). Lets MuxerAVI be used as a plain one-call-per-frame Print-like sink (e.g. from a camera driver, or an audio encoder) without the caller needing to know which addXxxFrame() applies.
Implements VideoOutput.
|
inlineprotected |
|
inlineprotected |
Writes the biCompression field: numeric BI_RGB(0)/BI_BITFIELDS(3) for uncompressed RGB, or the FOURCC codec tag for everything else
|
inlineprotected |
|
inlineprotected |
|
inline |
Appends data to the currently open video frame - requires a prior beginFrame() (and a later endFrame()); use this for incremental/ streaming sources that hand over a frame in pieces. For a single complete frame per call, use write() (dispatches by getVideoInfo().format) or one of the addXxxFrame() methods instead.
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
protected |
|
protected |
|
staticprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protectedinherited |
|
protected |
|
protected |
|
protected |