AVI 播放器

[English]

该组件支持解析 AVI 文件,并按照 FPS 速率解析 AVI 文件,将音视频数据已回调的方式提供给用户。

AVI (Audio Video Interleave) 文件是一种多媒体容器格式,用于存储音频和视频数据。它可以包含多种编码格式的视频和音频流,并且支持不同的压缩方式。

该组件目前仅支持以下格式的音视频

Video:

  • MJPEG

  • H264

Audio:

  • PCM

API 参考

Header File

Functions

esp_err_t avi_player_play_from_memory(uint8_t *avi_data, size_t avi_size)

Plays an AVI file from memory. The buffer of the AVI will be passed through the set callback function.

This function initializes and plays an AVI file from a memory buffer.

参数
  • avi_data – Pointer to the AVI file data in memory.

  • avi_size – Size of the AVI file data in bytes.

返回

esp_err_t ESP_OK if successful, otherwise an error code.

esp_err_t avi_player_play_from_file(const char *filename)

Plays an AVI file from the filesystem. The buffer of the AVI will be passed through the set callback function.

This function initializes and plays an AVI file from the filesystem using its filename.

参数

filename – Path to the AVI file on the filesystem.

返回

esp_err_t ESP_OK if successful, otherwise an error code.

esp_err_t avi_player_get_video_buffer(void **buffer, size_t *buffer_size, video_frame_info_t *info, TickType_t ticks_to_wait)

Get one video frame from AVI stream.

参数
  • buffer[out] Pointer to external buffer to hold one frame

  • buffer_size[inout] Size of external buffer

  • info[out] Information of the video frame

  • ticks_to_wait[in] Maximum blocking time

返回

  • ESP_OK Success

  • ESP_ERR_TIMEOUT Timeout

  • ESP_ERR_INVALID_ARG NULL arguments

  • ESP_ERR_NO_MEM External buffer not enough

esp_err_t avi_player_get_audio_buffer(void **buffer, size_t *buffer_size, audio_frame_info_t *info, TickType_t ticks_to_wait)

Get the audio buffer from AVI file.

参数
  • buffer[out] pointer to the audio buffer

  • buffer_size[in] size of the audio buffer

  • info[out] audio frame information

  • ticks_to_wait[in] maximum blocking time in ticks

返回

  • ESP_OK on success

  • ESP_ERR_TIMEOUT if semaphore is not acquired before timeout

  • ESP_ERR_INVALID_ARG if buffer or info is NULL or buffer_size is zero

  • ESP_ERR_NO_MEM if buffer size is not enough

esp_err_t avi_player_play_stop(void)

Stop AVI player.

返回

  • ESP_OK: Stop AVI player successfully

  • ESP_ERR_INVALID_STATE: AVI player not playing

esp_err_t avi_player_init(avi_player_config_t config)

Initialize the AVI player.

参数

config[in] Configuration of AVI player

返回

  • ESP_OK: succeed

  • ESP_ERR_NO_MEM: Cannot allocate memory for AVI player

  • ESP_ERR_INVALID_STATE: AVI player has already been initialized

esp_err_t avi_player_deinit(void)

Deinitializes the AVI player.

This function deinitializes and cleans up resources used by the AVI player.

返回

esp_err_t ESP_OK if successful, otherwise an error code.

Structures

struct video_frame_info_t

video frame info

Public Members

uint32_t width

Width of image in pixels

uint32_t height

Height of image in pixels

video_frame_format frame_format

Pixel data format

struct audio_frame_info_t

audio frame info

Public Members

uint8_t channel

Audio output channel

uint8_t bits_per_sample

Audio bits per sample

uint32_t sample_rate

Audio sample rate

audio_frame_format format

Audio format

struct frame_data_t

frame data

Public Members

uint8_t *data

Image data for this frame

size_t data_bytes

Size of image data buffer

frame_type_t type

Frame type: video or audio

video_frame_info_t video_info

Video frame info

audio_frame_info_t audio_info

Audio frame info

union frame_data_t::[anonymous] [anonymous]

frame info

struct avi_player_config_t

avi player config

Public Members

size_t buffer_size

Internal buffer size

video_write_cb video_cb

Video frame callback

audio_write_cb audio_cb

Audio frame callback

audio_set_clock_cb audio_set_clock_cb

Audio set clock callback

avi_play_end_cb avi_play_end_cb

AVI play end callback

UBaseType_t priority

FreeRTOS task priority

BaseType_t coreID

ESP32 core ID

void *user_data

User data

Type Definitions

typedef void (*video_write_cb)(frame_data_t *data, void *arg)
typedef void (*audio_write_cb)(frame_data_t *data, void *arg)
typedef void (*audio_set_clock_cb)(uint32_t rate, uint32_t bits_cfg, uint32_t ch, void *arg)
typedef void (*avi_play_end_cb)(void *arg)

Enumerations

enum video_frame_format

video frame format

Values:

enumerator FORMAT_MJEPG
enumerator FORMAT_H264
enum audio_frame_format

audio frame format

Values:

enumerator FORMAT_PCM
enum frame_type_t

frame type: video or audio

Values:

enumerator FRAME_TYPE_VIDEO
enumerator FRAME_TYPE_AUDIO