Overview
The example creates a 440Hz tone and encodes it to an MP2 audio file. It demonstrates:- Finding and configuring an audio encoder
- Selecting appropriate encoder parameters
- Generating audio samples
- The send/receive encoding pattern
- Flushing the encoder
Key Components
Encoder Setup
Selecting Encoder Parameters
Helper functions choose compatible parameters:Frame Allocation
Encoding Function
Generating Audio Samples
The example generates a sine wave:Important Patterns
Frame Writability
Always ensure frames are writable before modification:Flushing
Flush the encoder by sending NULL:Packet Management
Always unref packets after use:Channel Layout Selection
Usage
Related Examples
- Audio Decoding - Decode compressed audio
- Video Encoding - Encode video frames
- Transcoding - Complete encode/decode pipeline