AVbin  Version 10
Cross-platform audio/video media decoding library with long-term ABI support.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
AVbin Documentation

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

  1. (Optionally) call avbin_have_feature() to check which features are available. This is only needed if your application may be deployed in environments with older versions of AVbin than you are developing to.
  2. Initialize AVbin by calling avbin_init_options()
  3. Open a sound or video file using avbin_open_filename()
  4. 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.
  5. 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)
  6. 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.