Module Avutil.Frame

Frames: the properties common to audio and video frames.

type 'media t

One decoded audio or video frame. 'media is audio or video and matches the content of the frame.

The value owns one FFmpeg frame, which is released when the value is collected; there is no explicit close. The data buffers of the frame are reference counted by FFmpeg and may be shared with other frames. The size of those buffers is reported to the garbage collector.

A function of the bindings that takes a frame leaves it unchanged and usable, apart from the setters below and Video.frame_visit with ~make_writable:true. A frame has no lock: any number of threads may read one at the same time, and a thread that changes one must be its only user at that moment. The bindings do not detect a violation.

val pts : _ t -> Stdlib.Int64.t option

The presentation timestamp of the frame, in units of the time base the frame is handled with. None when the frame has none (FFmpeg's AV_NOPTS_VALUE).

val set_pts : _ t -> Stdlib.Int64.t option -> unit

set_pts frame pts writes the presentation timestamp of frame, None meaning no timestamp. It writes the same value as the best-effort timestamp, so best_effort_timestamp agrees with pts afterwards.

val duration : _ t -> Stdlib.Int64.t option

The duration of the frame, in the same units as pts. None when the duration is 0, which FFmpeg reads as unknown.

val set_duration : _ t -> Stdlib.Int64.t option -> unit

set_duration frame duration writes the duration of frame, None being stored as 0.

val pkt_dts : _ t -> Stdlib.Int64.t option

The decoding timestamp copied from the packet that produced the frame. None when the frame has none (AV_NOPTS_VALUE).

val set_pkt_dts : _ t -> Stdlib.Int64.t option -> unit

set_pkt_dts frame dts writes that decoding timestamp, None meaning no timestamp.

val metadata : _ t -> (string * string) list

The metadata of the frame as (key, value) pairs, in the order FFmpeg holds them. The strings are copies.

val set_metadata : _ t -> (string * string) list -> unit

set_metadata frame l replaces the whole metadata of frame with l. Entries that are absent from l are removed, a key that appears several times in l keeps its last value, and the empty list leaves the frame with no metadata. A key or a value ends at its first NUL byte.

  • raises Error

    when FFmpeg cannot build the new metadata. The metadata of the frame is then unchanged.

val best_effort_timestamp : _ t -> Stdlib.Int64.t option

The timestamp FFmpeg estimates for the frame when decoding, which its own components read. None when the frame has none (AV_NOPTS_VALUE). FFmpeg fills it only when decoding; set_pts writes it too.

val side_data : _ t -> Frame_side_data.raw list

Every side-data entry of the frame, in the frame's order. An entry whose kind the bindings have no constructor for is left out.

val find_side_data : _ t -> Frame_side_data.kind -> Frame_side_data.raw option

find_side_data frame kind is the first entry of that kind, None when the frame has none. It copies that entry only.

val add_side_data : _ t -> Frame_side_data.raw -> unit

add_side_data frame entry attaches a copy of entry. An entry of the same kind is replaced, unless the kind has the `Multi property, in which case the entry is appended. On failure the frame is unchanged.

val remove_side_data : _ t -> Frame_side_data.kind -> unit

remove_side_data frame kind removes every entry of that kind.

val dup : 'media t -> 'media t

dup frame is a new frame with a copy of the properties, the metadata and the side data of frame. Both frames reference the same data buffers: no sample or pixel is copied. Changing the properties or the side data of one leaves the other unchanged.