Delphi Ogg Streamer Library
Ogg Streamer Library is a component for use in Win32 and Win64 (9x/ME/2K/XP/Vista/7/8/10), OSX, iOS, Android and Linux software.
Ogg stream editor class, read, create and manipulate Ogg streams.
- Read Ogg pages as Ogg pages or just the raw page data
- Write Ogg pages (wrap data streams in Ogg container format)
- Access separate Ogg streams in the container stream
- Pure Delphi code, no external dependencies
- Delphi XE2 64bit and OSX, Delphi XE5 iOS and Android, Lazarus/Free pascal compatible
- Ogg Opus Bit Rate Scanner - scan an Opus Audio Codec file and calculate it's real bit rate
- Ogg Stream Viewer - view an Ogg file's page layout
- Ogg Stream Wrap-UnWrap - wrap a data stream into Ogg container, un-wrap data from Ogg container
If you are interested in ID3v1 and ID3v2 tagging unit, please follow this link: ID3v2 Library
If you are interested in an APEv2 tagging unit, please follow this link: APEv2 Library
If you are interested in MP4 tagging unit, please follow this link: MP4 Tag Library
If you are interested in an Ogg Vorbis and Opus tagging unit, please follow this link: Ogg Vorbis and Opus Tag Library
If you are interested in Flac tagging unit, please follow this link: Flac Tag Library
If you are interested in WMA tagging unit, please follow this link: WMA Tag Library
If you are interested in WAV tagging unit, please follow this link: WAV Tag Library
All the above mentioned tagging components are also available as a part of Tags Library.
Some usage examples
To copy a range of pages seek to the page wanted - for example an Ogg Vorbis audio file, frame containing samples from 44100 * 2 sample (from 2 seconds for a 44100Hz audio file):
Page := TMemoryStream.Create;
OutputStream := TFileStream.Create(OutputFileName, fmCreate);
while OggStreamer.GetNextPageHeader(OggHeader) do begin
if OggHeader.AbsolutePosition = 44100 * 2 then begin
//* Now copy the pages needed
Finished := False;
if NOT OggStreamer.GetNextPage(Page, OggHeader) then begin
//* No more pages left
//* Copy 44100 * 3 length audio
if OggHeader.AbsolutePosition > 44100 * 5 then begin
//* Set end of stream flag
OggHeader.TypeFlag := 4; //* OggHeader.TypeFlag := OggHeader.TypeFlag OR $04;
Finished := True;
//* Adjust granule position (decrement by where we started)
OggHeader.AbsolutePosition := OggHeader.AbsolutePosition - 44100 * 2;
//* Adjust and replace the header
Note that for an Ogg Vorbis audio you need to copy the first page and the following pages containing the Vorbis comments before copying any audio pages.
Creating a new Ogg stream:
Create a new TOggStreamer class and add data with the function AppendStream() which returns a new page number that can be used in the next call for 'PageNumber'.
TOggStreamer.WriteSegmentSize defines the page size, bigger data streams will be split into multiple Ogg pages. Default value is 17. To calculate the page data size: WriteSegmentSize * High(Byte) - the data stream should be smaller then this value else it will be split into multiple Ogg pages.
Set the 'SetStreamStartFlag' to 'True' for first page and 'SetStreamEndFlag' to 'True' for last page. Specify a stream serial number for the page and adjust the 'AbsolutePosition' granule position to the wanted values.
It's possible to multiplex multiple streams, by defining a different serial number for each stream, and write the data streams page by page (first stream first page, second stream first page, first stream's next page, second stream's next page, etc.). Such an Ogg stream could be easily decoded by the component when it's needed.
Ogg Streamer Library in shareware and commercial software?
The component is free for use in free software. If you like it and use it in a shareware or commercial (or any other money making - advertising, in app. selling, etc.) product you need to buy a license.