EDA.Voice.Ogg (EDA v0.3.0)

Copy Markdown View Source

OGG page parser for extracting Opus frames from an OGG/Opus stream.

When FFmpeg outputs with -f ogg, audio data is wrapped in OGG pages with proper frame boundaries. This module parses those pages to extract individual Opus frames, solving the frame merging issue that occurs with raw -f data output where Erlang's port :stream mode can concatenate multiple frames into a single message.

Summary

Functions

Extracts opus frames from a buffer of OGG data.

Functions

extract_frames(buffer, headers_to_skip \\ 0)

@spec extract_frames(binary(), non_neg_integer()) ::
  {[binary()], binary(), non_neg_integer()}

Extracts opus frames from a buffer of OGG data.

Returns {frames, remaining_buffer, headers_to_skip} where:

  • frames is a list of individual opus frame binaries
  • remaining_buffer is leftover data awaiting more input
  • headers_to_skip is the updated count of header pages still to skip

A new OGG/Opus stream has 2 header pages (OpusHead, OpusTags) that must be skipped before audio data begins.