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 =
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.
= 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 =
A data encoder is an encoder for either a audio or a video track.
type
stream_encoder = {
}
The full stream encoder type.
type
t
Main type for the ogg encoder
type
state =
You may register new tracks on state Eos or Bos.
You can't register new track on state Streaming.
API
Usage:
Encoding:
create ~skeleton name
: create a new encoder
register_track encoder stream_encoder
: register a new track
- ibid
- (...)
streams_start encoder
: start the tracks (optional)
encode encoder track_serial track_data
: encode data for one track
- ibid
- (...)
- (encode data for other tracks)
end_of_track encoder track_serial
: ends a track. (track end do not need to be simultaneous)
- (...)
end_of_stream encoder
: ends all tracks as well as the encoder. Set Eos state on the encoder.
register_track encoder stream_encoder
: register a new track, starts a new sequentialized stream
- And so on..
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..
: 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