AVI Player
This component supports parsing AVI files and processes them at the FPS rate, providing audio and video data to the user through callbacks.
AVI (Audio Video Interleave) files are a multimedia container format used to store audio and video data. They can contain video and audio streams encoded in various formats and support different compression methods.
This component currently supports the following audio and video formats:
Video: - MJPEG - H264
Audio: - PCM
API Reference
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.
- Parameters
avi_data – Pointer to the AVI file data in memory.
avi_size – Size of the AVI file data in bytes.
- Returns
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.
- Parameters
filename – Path to the AVI file on the filesystem.
- Returns
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.
- Parameters
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
- Returns
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.
- Parameters
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
- Returns
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.
- Returns
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.
- Parameters
config – [in] Configuration of AVI player
- Returns
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.
- Returns
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
-
uint32_t width
-
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
-
uint8_t channel
-
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
-
uint8_t *data
-
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
-
size_t buffer_size
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)