11#define LIST_HEADER_SIZE 12
12#define CHUNK_HEADER_SIZE 8
42 return vector.data() !=
nullptr;
63 return ptr ==
nullptr ? -1l : ptr -
vector.data();
176 void set(
size_t currentPos,
const char *
id,
size_t size,
303 bool isValid(
const uint8_t *data,
size_t len)
override {
304 return len >= 12 && memcmp(data,
"RIFF", 4) == 0 &&
305 memcmp(data + 8,
"AVI ", 4) == 0;
359 virtual size_t write(
const uint8_t *data,
size_t len)
override {
360 LOGD(
"write: %d", (
int)len);
361 int result =
parse_buffer.writeArray((uint8_t *)data, len);
622 LOGW(
"unknown subchunk '%s' at %d, skipping %d bytes",
710 uint16_t biBitCount) {
712 if (biCompression == 3)
715 auto is = [biCompression](
const char *fourcc) {
716 return memcmp(&biCompression, fourcc, 4) == 0;
718 if (is(
"H264") || is(
"h264") || is(
"X264") || is(
"x264") ||
719 is(
"avc1") || is(
"AVC1"))
721 if (is(
"MJPG") || is(
"mjpg"))
723 if (is(
"FMP4") || is(
"XVID") || is(
"DIVX") || is(
"DX50") ||
726 if (is(
"YUY2") || is(
"YUYV") || is(
"yuy2") || is(
"yuyv"))
728 if (is(
"I420") || is(
"IYUV"))
743 if (payload_left < 0) payload_left = 0;
744 long payload_to_write = min(to_write, payload_left);
747 LOGD(
"audio %d", (
int)to_write);
755 LOGD(
"video %d", (
int)to_write);
773 if (payload_to_write > 0) {
796 LOGD(
"skipping unknown subchunk %d", (
int)to_write);
807 if (
getStr(0, 4).equals(
"RIFF")) {
809 uint32_t header_file_size =
getInt(4);
814 header_file_size >= 0xFFFFFFF0 ? 0 : header_file_size + 8;
838 if (
getStr(0, 4).equals(
id)) {
847 if (list_id.
equals(
id) &&
getStr(0, 3).equals(
"LIST")) {
856 if (
getStr(0, 4).equals(
"LIST")) {
865 int chunk_size =
getInt(4);
877 if (
getStr(0, 4).equals(
"LIST") &&
getStr(8, 4).equals(
id)) {
905 LOGD(
"%s - %s (%d-%d) size:%d",
spaces.c_str(), result.
id(),
927 str.setCapacity(len + 1);
929 str.copyFrom((data + offset), len, 5);
936 uint32_t *result = (uint32_t *)(
parse_buffer.data() + offset);
994 const char *
mimeVideo()
override {
return "video/avi"; }
1021 if (
p_out ==
nullptr) {
1022 LOGE(
"output not defined");
1070 size_t written =
p_out->write(data, to_write);
1090 size_t write(
const uint8_t *data,
size_t len)
override {
1160 size_t written =
p_out->write(data, len);
1161 if (len % 2 != 0)
p_out->write((uint8_t)0);
1267 LOGW(
"getVideoInfo().format does not match the addXxxFrame() called");
1276 if (expected_size > 0 && len != expected_size) {
1277 LOGW(
"frame size %d does not match the expected %d bytes for %d x %d",
1278 (
int)len, (
int)expected_size, (
int)
video_cfg.width,
1285 uint8_t b[2] = {(uint8_t)(v & 0xFF), (uint8_t)((v >> 8) & 0xFF)};
1290 uint8_t b[4] = {(uint8_t)(v & 0xFF), (uint8_t)((v >> 8) & 0xFF),
1291 (uint8_t)((v >> 16) & 0xFF), (uint8_t)((v >> 24) & 0xFF)};
1296 for (
int j = 0; j < n; j++)
writeU8(0);
1315 uint32_t micros_per_frame =
1381 uint16_t block_align =
1383 uint32_t byte_rate = (uint32_t)
audio_info.sample_rate * block_align;
#define LIST_HEADER_SIZE
Definition ContainerAVI.h:11
#define CHUNK_HEADER_SIZE
Definition ContainerAVI.h:12
char[4] FOURCC
Four-character code identifier for AVI format.
Definition ContainerAVI.h:73
VideoFormat
Video codec/pixel-format identifier, shared by two unrelated uses: the (single) video stream of a con...
Definition VideoOutput.h:29
StreamContentType
Which track write() feeds, for muxers (MuxerAVI, MuxerMP4) that double as a plain,...
Definition Video.h:21
size_t videoFrameSizeBytes(VideoFormat format, uint16_t width, uint16_t height)
Fixed per-frame size (bytes) for a raw/uncompressed VideoFormat at the given resolution - 0 for compr...
Definition Video.h:27
AudioFormat
Audio format codes used by Microsoft e.g. in avi or wav files.
Definition AudioFormat.h:21
const char * toMime(AudioFormat format)
Provides the mime type for a AudioFormat wav code, or nullptr if not known/mapped.
Definition AudioFormat.h:300
bool isWavFormat(AudioFormat format)
True if the wav code is handled via the WAV decoder (i.e. toMime() maps it to "audio/wav": PCM and al...
Definition AudioFormat.h:350
@ MJPEG
Definition VideoOutput.h:31
@ MPEG4
Definition VideoOutput.h:32
@ RGB565
Definition VideoOutput.h:35
@ RAW
Definition VideoOutput.h:33
@ UNKNOWN
Definition VideoOutput.h:40
@ H264
Definition VideoOutput.h:30
@ I420
Definition VideoOutput.h:38
@ YUV422
Definition VideoOutput.h:34
@ Audio
Definition Video.h:21
@ Video
Definition Video.h:21
@ PCM
Definition AudioFormat.h:23
Definition ContainerAVI.h:75
uint32_t dwStreams
Definition ContainerAVI.h:84
uint32_t dwInitialFrames
Definition ContainerAVI.h:83
uint32_t dwMaxBytesPerSec
Definition ContainerAVI.h:79
uint32_t dwHeight
Definition ContainerAVI.h:87
uint32_t dwReserved[4]
Definition ContainerAVI.h:88
uint32_t dwFlags
Definition ContainerAVI.h:81
uint32_t dwPaddingGranularity
Definition ContainerAVI.h:80
uint32_t dwMicroSecPerFrame
Definition ContainerAVI.h:78
uint32_t dwSuggestedBufferSize
Definition ContainerAVI.h:85
uint32_t dwWidth
Definition ContainerAVI.h:86
uint32_t dwTotalFrames
Definition ContainerAVI.h:82