Module Avcodec.Packet_side_data

Side data of packets and of codec parameters: the kinds FFmpeg defines, raw entries and their typed content. A packet's side data applies to that packet; the side data of codec parameters applies to the whole stream.

type kind = [
  1. | `Palette
  2. | `New_extradata
  3. | `Param_change
  4. | `H263_mb_info
  5. | `Replaygain
  6. | `Displaymatrix
  7. | `Stereo3d
  8. | `Audio_service_type
  9. | `Quality_stats
  10. | `Fallback_track
  11. | `Cpb_properties
  12. | `Skip_samples
  13. | `Jp_dualmono
  14. | `Strings_metadata
  15. | `Subtitle_position
  16. | `Matroska_blockadditional
  17. | `Webvtt_identifier
  18. | `Webvtt_settings
  19. | `Metadata_update
  20. | `Mpegts_stream_id
  21. | `Mastering_display_metadata
  22. | `Spherical
  23. | `Content_light_level
  24. | `A53_cc
  25. | `Encryption_init_info
  26. | `Encryption_info
  27. | `Afd
  28. | `Prft
  29. | `Icc_profile
  30. | `Dovi_conf
  31. | `S12m_timecode
  32. | `Dynamic_hdr10_plus
  33. | `Iamf_mix_gain_param
  34. | `Iamf_demixing_info_param
  35. | `Iamf_recon_gain_info_param
  36. | `Ambient_viewing_environment
  37. | `Frame_cropping
  38. | `Lcevc
  39. | `_3d_reference_displays
  40. | `Rtcp_sr
  41. | `Exif
  42. | `Dynamic_hdr_smpte_2094_app5
  43. | `Hevc_conf
]
type raw = private {
  1. kind : kind;
  2. data : string;
}

One entry as its carrier holds it: its kind and a copy of its payload. The record is private: an entry comes from reading a packet or parameters, or from encode, never from arbitrary bytes, because FFmpeg reads a payload at the size its kind implies. For most kinds the payload is a C structure of the FFmpeg build in use: it must not be stored or sent to another process.

type replaygain = {
  1. track_gain : int;
  2. track_peak : int;
  3. album_gain : int;
  4. album_peak : int;
}

ReplayGain information, FFmpeg's AVReplayGain. track_gain and album_gain are in microbels: divide by 100000 to get decibels. FFmpeg's "unknown" gain is INT32_MIN, -2147483648. track_peak and album_peak are peak amplitudes where 100000 is full scale, 0 when unknown.

type cropping = Avutil.cropping = {
  1. top : int;
  2. bottom : int;
  3. left : int;
  4. right : int;
}
type t = [
  1. | `Replaygain of replaygain
  2. | `Strings_metadata of (string * string) list
  3. | `Metadata_update of (string * string) list
  4. | `Display_matrix of Avutil.Display_matrix.t
  5. | `Frame_cropping of cropping
]

The kinds whose content the bindings translate:

  • `Replaygain: ReplayGain information of an audio stream;
  • `Strings_metadata: a list of key and value pairs;
  • `Metadata_update: a list of key and value pairs, the updated metadata that appeared in the stream;
  • `Display_matrix: the transformation to show the video upright;
  • `Frame_cropping: the borders the container asks to discard.
val kinds : kind list

Every kind of the installed headers, in FFmpeg's enumeration order.

val name : kind -> string

FFmpeg's name of the kind, empty when it has none.

val decode : raw -> t option

The content of an entry. None for a kind outside t and for a payload too short for its kind.

val encode : t -> raw

The entry holding a content. decode (encode d) is Some d.

For `Replaygain, each gain must fit a signed 32-bit integer and each peak an unsigned 32-bit integer; each field of a `Frame_cropping an unsigned 32-bit integer. For the two metadata kinds, each key and value ends at its first NUL byte, and a later pair replaces an earlier pair of the same key, whatever its case.

  • raises Avutil.Error

    with `Failure _ when a number is out of range.

val display_matrix : raw list -> Avutil.Display_matrix.t option

The matrix of the first entry that holds one.

val cropping : raw list -> cropping option

The cropping of the first entry that holds one.