AVbin: Main Page

- Main Page
- Data Structures
- Files

# AVbin Documentation

To open a file and prepare it for decoding, the general procedure is

1. Initialise AVbin by calling avbin_init()
2. Open a file using avbin_open_filename()
3. Retrieve details of the file using avbin_file_info(). The resulting _AVbinFileInfo structure includes details such as:
   - Start time and duration
   - Number of audio and video streams
   - Metadata such as title, artist, etc.
4. Examine details of each stream using avbin_stream_info(), passing in each stream index as an integer from 0 to n_streams. For video streams, the _AVbinStreamInfo structure includes
   - Video width and height, in pixels
   - Pixel aspect ratio, expressed as a fraction
   For audio streams, the structure includes
   - Sample rate, in Hz
   - Bits per sample
   - Channels (monoaural, stereo, or multichannel surround)
5. For each stream you intend to decode, call avbin_open_stream().

When all information has been determined and the streams are open, you can proceed to read and decode the file:

1. Call avbin_read() to read a packet of data from the file.
2. Examine the resulting _AVbinPacket structure for the stream_index, which indicates how the packet should be decoded. If the stream is not one that you have opened, you can discard the packet and continue with step 1 again.
3. To decode an audio packet, repeatedly pass the data within the packet to avbin_decode_audio(), until there is no data left to consume or an error is returned.
4. To decode a video packet, pass the data within the packet to avbin_decode_video(), which will decode a single image in RGB format.
5. Synchronise audio and video data by observing the _AVbinPacket::timestamp member.

When decoding is complete, call avbin_close_stream() on each stream and avbin_close_file() on the open file.