Module Ogg_muxer


module Ogg_muxer: sig .. end
Ogg Stream Encoder

val log : Dtools.Log.t

Types


exception Invalid_data
exception Invalid_usage
type audio = float array array 
Audio data type
type video = Video.buffer 
Video data type

type 'a data = {
   data : 'a;
   offset : int;
   length : int;
}
A data unit

type track_data =
| Audio_data of audio data
| Video_data of video data
A track data is a data unit of either audio or video.
type 'a track_encoder = 'a data -> Ogg.Stream.t -> (Ogg.Page.t -> unit) -> unit 
A track encoder takes the track data, the ogg logical stream, and fills the stream. If the encoding process outputs ogg pages, then the encoder should use the last argument to add its pages to the stream.
type header_encoder = Ogg.Stream.t -> Ogg.Page.t 
Returns the first page of the stream, to be placed at the very beginning.

type position =
| Unknown
| Time of float
Return the end time of a page, in milliseconds.
type page_end_time = Ogg.Page.t -> position 
Type for a function returning a page's ending time.
type fisbone_packet = Ogg.Stream.t -> Ogg.Stream.packet option 
Returns an optional fisbone packet, which will contain the data for this stream to put in the ogg skeleton, if enabled in the encoder.
type stream_start = Ogg.Stream.t -> Ogg.Page.t list 
Returns the remaining header data, before data encoding starts.
type end_of_stream = Ogg.Stream.t -> unit 
Ends the track.

type data_encoder =
| Audio_encoder of audio track_encoder
| Video_encoder of video track_encoder
A data encoder is an encoder for either a audio or a video track.

type stream_encoder = {
   header_encoder : header_encoder;
   fisbone_packet : fisbone_packet;
   stream_start : stream_start;
   data_encoder : data_encoder;
   end_of_page : page_end_time;
   end_of_stream : end_of_stream;
}
The full stream encoder type.
type t 
Main type for the ogg encoder

type state =
| Eos
| Streaming
| Bos
You may register new tracks on state Eos or Bos. You can't register new track on state Streaming.

API



Usage:

Encoding:

You get encoded data by calling get_data, peek_data.

See: http://xiph.org/ogg/doc/oggstream.html for more details on the specifications of an ogg stream. This API reflects exactly what is recomended to do.

val create : skeleton:bool -> string -> t
Create a new encoder. Add an ogg skeleton if skeleton is true.
val state : t -> state
Get the state of an encoder.
val get_data : t -> string
Get and remove encoded data..
val get_header : t -> string
Get header of a stream.
val peek_data : t -> string
Peek encoded data without removing it.
val register_track : ?fill:int -> t -> stream_encoder -> nativeint
Register a new track to the stream. The state needs to be Bos or Eos.

fill parameter is used to try to control ogg logical page's size. See Ogg.get_page for more details.

Returns the serial number of the registered ogg stream.

val streams_start : t -> unit
Start streams, set state to Streaming.
val encode : t -> nativeint -> track_data -> unit
Encode data. Implicitely calls streams_start if not called before. Fails if state is not Streaming
val end_of_track : t -> nativeint -> unit
Finish a track. Raises Not_found if no such track exists.
val end_of_stream : t -> unit
Ends all tracks, flush remaining encoded data. Set state to Eos.

Utils


val flush_pages : Ogg.Stream.t -> Ogg.Page.t list
flush all availables pages from an ogg stream