package ffmpeg-av
Install
Dune Dependency
Authors
Maintainers
Sources
md5=671e477501e6f5928517dd7034f27d07
sha512=a94a21c73661b3ee9bcc8a9d6539693977b18c4fa1065701fc7b00cf0f148c154dc6b21790193fae157dbded811e28538cbe8e8fb7bcf426900d30d453225d50
doc/ffmpeg-av/Av/index.html
Module Av
Source
This module perform demuxing then decoding for reading and coding then muxing for writing multimedia container formats.
Format
Input
val open_input :
?interrupt:(unit -> bool) ->
?format:(Avutil.input, _) Avutil.format ->
?opts:Avutil.opts ->
string ->
Avutil.input Avutil.container
Av.open_input url
open the input url
(a file name or http URL). After returning, if opts
was passed, unused options are left in the hash table. Raise Error if the opening failed.
val open_input_stream :
?format:(Avutil.input, _) Avutil.format ->
?opts:Avutil.opts ->
?seek:seek ->
read ->
Avutil.input Avutil.container
Av.open_input_stream read
creates an input stream from the given read callback. Exceptions from the callback are caught and result in a native Avutil.Error `Unknown
error.
val get_input_duration :
?format:Avutil.Time_format.t ->
Avutil.input Avutil.container ->
Int64.t option
Av.get_input_duration ~format:fmt input
return the duration of an input
in the fmt
time format (in second by default).
Return the input tag (key, vlue) list.
Return a value of type obj
, suited for use with Avutils.Options
getters.
Input/output, audio/video/subtitle, mode stream type
val get_audio_streams :
Avutil.input Avutil.container ->
(int * (Avutil.input, Avutil.audio, 'a) stream * Avutil.audio Avcodec.params)
list
Return the audio stream list of the input. The result is a list of tuple containing the index of the stream in the container, the stream and the codec of the stream.
val get_video_streams :
Avutil.input Avutil.container ->
(int * (Avutil.input, Avutil.video, 'a) stream * Avutil.video Avcodec.params)
list
Same as Av.get_audio_streams
for the video streams.
val get_subtitle_streams :
Avutil.input Avutil.container ->
(int
* (Avutil.input, Avutil.subtitle, 'a) stream
* Avutil.subtitle Avcodec.params)
list
Same as Av.get_audio_streams
for the subtitle streams.
val find_best_audio_stream :
Avutil.input Avutil.container ->
int * (Avutil.input, Avutil.audio, 'a) stream * Avutil.audio Avcodec.params
Return the best audio stream of the input. The result is a tuple containing the index of the stream in the container, the stream and the codec of the stream. Raise Error if no stream could be found.
val find_best_video_stream :
Avutil.input Avutil.container ->
int * (Avutil.input, Avutil.video, 'a) stream * Avutil.video Avcodec.params
Same as Av.find_best_audio_stream
for the video streams.
val find_best_subtitle_stream :
Avutil.input Avutil.container ->
int
* (Avutil.input, Avutil.subtitle, 'a) stream
* Avutil.subtitle Avcodec.params
Same as Av.find_best_audio_stream
for the subtitle streams.
Return the input container of the input stream.
Av.get_codec stream
return the codec of the stream
. Raise Error if the codec allocation failed.
Av.get_time_base stream
return the time base of the stream
.
Av.set_time_base stream time_base
set the stream
time base to time_base
.
Av.get_frame_size stream
return the frame size for the given audio stream.
Av.get_pixel_aspect stream
return the pixel aspect of the stream
.
Same as Av.get_input_duration
for the input streams.
Same as Av.get_input_metadata
for the input streams.
For the use of a specific decoder for the given input stream.
type input_result = [
| `Audio_packet of int * Avutil.audio Avcodec.Packet.t
| `Audio_frame of int * Avutil.audio Avutil.frame
| `Video_packet of int * Avutil.video Avcodec.Packet.t
| `Video_frame of int * Avutil.video Avutil.frame
| `Subtitle_packet of int * Avutil.subtitle Avcodec.Packet.t
| `Subtitle_frame of int * Avutil.subtitle Avutil.frame
]
val read_input :
?audio_packet:(Avutil.input, Avutil.audio, [ `Packet ]) stream list ->
?audio_frame:(Avutil.input, Avutil.audio, [ `Frame ]) stream list ->
?video_packet:(Avutil.input, Avutil.video, [ `Packet ]) stream list ->
?video_frame:(Avutil.input, Avutil.video, [ `Frame ]) stream list ->
?subtitle_packet:(Avutil.input, Avutil.subtitle, [ `Packet ]) stream list ->
?subtitle_frame:(Avutil.input, Avutil.subtitle, [ `Frame ]) stream list ->
Avutil.input Avutil.container ->
input_result
Reads the selected streams if any or all streams otherwise. Return the next Audio
Video
or Subtitle
index and packet or frame of the input or Error `Eof
if the end of the input is reached. Raise Error if the reading failed.
Only packet and frames from the specified streams are returned.
Seek mode.
val seek :
?flags:seek_flag list ->
?stream:(Avutil.input, _, _) stream ->
?min_ts:Int64.t ->
?max_ts:Int64.t ->
fmt:Avutil.Time_format.t ->
ts:Int64.t ->
Avutil.input Avutil.container ->
unit
Av.seek ?flags ?stream ?min_ts ?max_ts ~fmt ~ts container
seek in the container container
to position ts
. You can pass an optional stream
to use for seeking, max_ts
and min_ts
to force seeking to happen within a given timestamp window and flags
to speficy certain property of the seeking operation. Raise Error if the seeking failed.
Output
val open_output :
?interrupt:(unit -> bool) ->
?format:(Avutil.output, _) Avutil.format ->
?opts:Avutil.opts ->
string ->
Avutil.output Avutil.container
Av.open_output ?interrupt ?format ?opts filename
open the output file named filename
. interrupt
is used to interrupt blocking functions, format
may contain an optional format, opts
may contain any option settable on the stream's internal AVFormat. After returning, if opts
was passed, unused options are left in the hash table. Raise Error if the opening failed.
val open_output_stream :
?opts:Avutil.opts ->
?seek:seek ->
write ->
(Avutil.output, _) Avutil.format ->
Avutil.output Avutil.container
Av.open_stream callbacks
open the output container with the given callbacks. opts
may contain any option settable on Ffmpeg avformat. After returning, if opts
was passed, unused options are left in the hash table. Raise Error if the opening failed. Exceptions from the callback are caught and result in a native Avutil.Error `Unknown
error.
Returns true
if the output has already started, in which case no new * stream or metadata can be added.
Av.set_output_metadata dst tags
set the metadata of the dst
output with the tags
tag list. This must be set before starting writing streams. Raise Error if a writing already taken place or if the setting failed.
Same as Av.set_output_metadata
for the output streams.
Return the output container of the output stream.
val new_stream_copy :
params:'mode Avcodec.params ->
Avutil.output Avutil.container ->
(Avutil.output, 'mode, [ `Packet ]) stream
val new_audio_stream :
?opts:Avutil.opts ->
?channels:int ->
?channel_layout:Avutil.Channel_layout.t ->
sample_rate:int ->
sample_format:Avutil.Sample_format.t ->
time_base:Avutil.rational ->
codec:[ `Encoder ] Avcodec.Audio.t ->
Avutil.output Avutil.container ->
(Avutil.output, Avutil.audio, [ `Frame ]) stream
Add a new audio stream to the given container. Stream only supports frames and encodes its input.
opts
may contain any option settable on the stream's internal AVCodec. After returning, if opts
was passed, unused options are left in the hash table.
At least one of channels
or channel_layout
must be passed.
Frames passed to this stream for encoding must have a PTS set according to the given time_base
. 1/sample_rate
is usually a good value for the time_base
.
Please note that some codec require a fixed frame size, denoted by the absence of the `Variable_frame_size
codec capabilities. In this case, the user is expected to pass frames containing exactly Av.get_frame_size stream
.
Avfilter
can be used to slice frames into frames of fixed size. See Avfilter.Utils.convert_audio
for an example.
Raise Error if the opening failed.
val new_video_stream :
?opts:Avutil.opts ->
?frame_rate:Avutil.rational ->
?hardware_context:Avcodec.Video.hardware_context ->
pixel_format:Avutil.Pixel_format.t ->
width:int ->
height:int ->
time_base:Avutil.rational ->
codec:[ `Encoder ] Avcodec.Video.t ->
Avutil.output Avutil.container ->
(Avutil.output, Avutil.video, [ `Frame ]) stream
Add a new video stream to the given container. Stream only supports frames and encodes its input.
opts
may contain any option settable on the stream's internal AVCodec. After returning, if opts
was passed, unused options are left in the hash table.
Frames passed to this stream for encoding must have a PTS set according to the given time_base
. 1/frame_rate
is usually a good value for the time_base
.
hardware_context
can be used to pass optional hardware device and frame context to enable hardward encoding on this stream.
Raise Error if the opening failed.
val new_subtitle_stream :
?opts:Avutil.opts ->
time_base:Avutil.rational ->
codec:[ `Encoder ] Avcodec.Subtitle.t ->
Avutil.output Avutil.container ->
(Avutil.output, Avutil.subtitle, [ `Frame ]) stream
Add a new subtitle stream to the given container. Stream only supports frames and encodes its input.
opts
may contain any option settable on the stream's internal AVCodec. After returning, if opts
was passed, unused options are left in the hash table.
Raise Error if the opening failed.
Return a codec attribute suitable for HLS playlists when available.
Return the stream's bitrate when available, suitable for HLS playlists.
val write_packet :
(Avutil.output, 'media, [ `Packet ]) stream ->
Avutil.rational ->
'media Avcodec.Packet.t ->
unit
Av.write_packet os time_base pkt
write the pkt
packet to the os
output stream. time_base
is the packet's PTS/DTS/duration time base. Raise Error if the writing failed.
Av.write_frame os frm
write the frm
frame to the os
output stream.
Frame PTS should be set and counted in units of time_base
, as passed when creating the stream
Raise Error if the writing failed.
true
if the last processed frame was a video key frame.
Av.write_audio_frame dst frm
write the frm
audio frame to the dst
output audio container. Raise Error if the output format is not defined or if the output media type is not compatible with the frame or if the writing failed.
Same as Av.write_audio_frame
for output video container.
Flush the underlying muxer.
Close an input or output container.