Skip to main content

av_frame_to_audio_frame

Function av_frame_to_audio_frame 

Source
pub unsafe fn av_frame_to_audio_frame(
    av_frame: *const AVFrame,
    time_base: Timebase,
) -> Result<AudioFrame<SampleFormat, AudioChannelLayout, AudioFrameExtra, FfmpegBuffer>, ConvertError>
Expand description

Converts an FFmpeg audio AVFrame into a mediadecode::AudioFrame.

The plane payloads are zero-copy views into the source frame’s AVBufferRef entries (the corresponding data[i] is always covered by exactly one of buf[i] per FFmpeg’s contract). Channel counts above 8 (which would spill into extended_buf) are clamped to 8 — the rare cases where this matters can read the source AVFrame directly.

§Safety

av_frame must be a live *const AVFrame for the duration of this call and must describe an audio frame (format is an AVSampleFormat, nb_samples > 0, and data[] / buf[] populated).