1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
4 .. _VIDIOC_G_ENC_INDEX:
6 ************************
7 ioctl VIDIOC_G_ENC_INDEX
8 ************************
13 VIDIOC_G_ENC_INDEX - Get meta data about a compressed video stream
18 .. c:macro:: VIDIOC_G_ENC_INDEX
20 ``int ioctl(int fd, VIDIOC_G_ENC_INDEX, struct v4l2_enc_idx *argp)``
26 File descriptor returned by :c:func:`open()`.
29 Pointer to struct :c:type:`v4l2_enc_idx`.
34 The :ref:`VIDIOC_G_ENC_INDEX <VIDIOC_G_ENC_INDEX>` ioctl provides meta data about a compressed
35 video stream the same or another application currently reads from the
36 driver, which is useful for random access into the stream without
39 To read the data applications must call :ref:`VIDIOC_G_ENC_INDEX <VIDIOC_G_ENC_INDEX>` with a
40 pointer to a struct :c:type:`v4l2_enc_idx`. On success
41 the driver fills the ``entry`` array, stores the number of elements
42 written in the ``entries`` field, and initializes the ``entries_cap``
45 Each element of the ``entry`` array contains meta data about one
46 picture. A :ref:`VIDIOC_G_ENC_INDEX <VIDIOC_G_ENC_INDEX>` call reads up to
47 ``V4L2_ENC_IDX_ENTRIES`` entries from a driver buffer, which can hold up
48 to ``entries_cap`` entries. This number can be lower or higher than
49 ``V4L2_ENC_IDX_ENTRIES``, but not zero. When the application fails to
50 read the meta data in time the oldest entries will be lost. When the
51 buffer is empty or no capturing/encoding is in progress, ``entries``
54 Currently this ioctl is only defined for MPEG-2 program streams and
55 video elementary streams.
57 .. tabularcolumns:: |p{3.8cm}|p{5.6cm}|p{8.1cm}|
59 .. c:type:: v4l2_enc_idx
61 .. flat-table:: struct v4l2_enc_idx
68 - The number of entries the driver stored in the ``entry`` array.
71 - The number of entries the driver can buffer. Must be greater than
75 - Reserved for future extensions. Drivers must set the
77 * - struct :c:type:`v4l2_enc_idx_entry`
78 - ``entry``\ [``V4L2_ENC_IDX_ENTRIES``]
79 - Meta data about a compressed video stream. Each element of the
80 array corresponds to one picture, sorted in ascending order by
84 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
86 .. c:type:: v4l2_enc_idx_entry
88 .. flat-table:: struct v4l2_enc_idx_entry
95 - The offset in bytes from the beginning of the compressed video
96 stream to the beginning of this picture, that is a *PES packet
97 header* as defined in :ref:`mpeg2part1` or a *picture header* as
98 defined in :ref:`mpeg2part2`. When the encoder is stopped, the
99 driver resets the offset to zero.
102 - The 33 bit *Presentation Time Stamp* of this picture as defined in
106 - The length of this picture in bytes.
109 - Flags containing the coding type of this picture, see
110 :ref:`enc-idx-flags`.
113 - Reserved for future extensions. Drivers must set the array to
116 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
120 .. flat-table:: Index Entry Flags
125 * - ``V4L2_ENC_IDX_FRAME_I``
127 - This is an Intra-coded picture.
128 * - ``V4L2_ENC_IDX_FRAME_P``
130 - This is a Predictive-coded picture.
131 * - ``V4L2_ENC_IDX_FRAME_B``
133 - This is a Bidirectionally predictive-coded picture.
134 * - ``V4L2_ENC_IDX_FRAME_MASK``
136 - *AND* the flags field with this mask to obtain the picture coding
142 On success 0 is returned, on error -1 and the ``errno`` variable is set
143 appropriately. The generic error codes are described at the
144 :ref:`Generic Error Codes <gen-errors>` chapter.