Skip to content

Commit 777d3a2

Browse files
authored
Added encoded_frame docs (#998)
* Added encoded_frame docs
1 parent cf41a43 commit 777d3a2

File tree

4 files changed

+101
-5
lines changed

4 files changed

+101
-5
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
EncodedFrame
2+
============
3+
4+
The ``EncodedFrame`` message is an output of the :ref:`VideoEncoder` node. This message is used to represent a frame that has been encoded by the VideoEncoder. It provides various properties and methods for interacting with the encoded frame data.
5+
6+
Structure
7+
#########
8+
9+
The ``EncodedFrame`` class inherits from ``Buffer`` and includes several nested classes and methods for accessing and modifying frame properties. Here are the primary components of the ``EncodedFrame`` class:
10+
11+
- ``FrameType``: Enumerates the types of frames that can be encoded (I, P, B, Unknown).
12+
- ``Profile``: Indicates the encoding profile used (AVC, HEVC, JPEG).
13+
14+
FrameType
15+
---------
16+
17+
The ``FrameType`` class identifies the type of the encoded frame. The available types are:
18+
19+
- **B**: Represents a bi-directional predicted frame.
20+
- **I**: Represents an intra-coded frame.
21+
- **P**: Represents a predicted frame.
22+
- **Unknown**: Used when the frame type cannot be determined.
23+
24+
Profile
25+
-------
26+
27+
The ``Profile`` class specifies the encoding profile used for the frame. The supported profiles are:
28+
29+
- **AVC**: H.264/AVC encoding profile.
30+
- **HEVC**: H.265/HEVC encoding profile.
31+
- **JPEG**: JPEG encoding profile.
32+
33+
34+
Reference
35+
#########
36+
37+
.. tabs::
38+
39+
.. tab:: Python
40+
41+
.. autoclass:: depthai.EncodedFrame
42+
:members:
43+
:inherited-members:
44+
:noindex:
45+
46+
.. tab:: C++
47+
48+
.. doxygenclass:: dai::EncodedFrame
49+
:project: depthai-core
50+
:members:
51+
:private-members:
52+
:undoc-members:
53+
54+
.. include:: ../../includes/footer-short.rst

docs/source/components/nodes/video_encoder.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,18 @@ Inputs and Outputs
2828
.. code-block::
2929
3030
┌──────────────┐
31-
│ │
32-
input │ │bitstream
33-
─────────►│ VideoEncoder ├────────►
34-
│ │
35-
31+
│ │ bitstream
32+
input │ ├────────►
33+
─────────►│ VideoEncoder |
34+
│ │ out
35+
├────────►
3636
└──────────────┘
3737
3838
**Message types**
3939

4040
- :code:`input` - :ref:`ImgFrame` (NV12/GRAY8)
4141
- :code:`bitstream` - :ref:`ImgFrame`
42+
- :code:`out` - :ref:`EncodedFrame`
4243

4344
Usage
4445
#####
@@ -101,6 +102,7 @@ Examples of functionality
101102
- :ref:`RGB Encoding`
102103
- :ref:`Encoding Max Limit`
103104
- :ref:`RGB Encoding & MobilenetSSD`
105+
- :ref:`Video Encoded Frame Type`
104106

105107
Reference
106108
#########
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
Video Encoded Frame Type
2+
========================
3+
4+
This example showcases how to compress and print the sequence of encoded frame types (I, P, B) encountered during the encoding process.
5+
6+
7+
Example script output
8+
#####################
9+
10+
.. code-block::
11+
12+
~/depthai-python/examples$ python3 video_encoding.py
13+
Press Ctrl+C to stop encoding...
14+
To view the encoded data, convert the stream file (.h265) into a video file (.mp4) using a command below:
15+
ffmpeg -framerate 30 -i video.h265 -c copy video.mp4
16+
17+
1I,29P,1I,29P,1I,29P,1I,29P,1I,29P,1I,29P,1I,29P,1I,29P,1I,29P,1I,18P
18+
19+
This output indicates the script's real-time video encoding process, and it compresses the sequence of frame types encountered. After stopping the script, it provides instructions to convert the raw H.265 stream into a playable MP4 video file. The final line shows a compressed representation of the frame types sequence, indicating the count of consecutive P, B, and I frames.
20+
21+
Setup
22+
#####
23+
24+
.. include:: /includes/install_from_pypi.rst
25+
26+
Source code
27+
###########
28+
29+
.. tabs::
30+
31+
.. tab:: Python
32+
33+
Also `available on GitHub <https://github.com/luxonis/depthai-python/blob/main/examples/VideoEncoder/rgb_encoding_encodedframe.py>`__
34+
35+
.. literalinclude:: ../../../../examples/VideoEncoder/rgb_encoding_encodedframe.py
36+
:language: python
37+
:linenos:
38+
39+
.. include:: /includes/footer-short.rst

docs/source/tutorials/code_samples.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ are presented with code.
191191
- :ref:`RGB & Mono Encoding`- Encodes RGB (1080P, 30FPS) and both mono streams (720P, 30FPS) into :code:`.h265`/:code:`.h264` and saves them on the host
192192
- :ref:`Encoding Max Limit` - Encodes RGB (4k 25FPS) and both mono streams (720P, 25FPS) into :code:`.h265`/:code:`.h264` and saves them on the host
193193
- :ref:`RGB Full Resolution Saver` - Saves full resolution RGB images (4k) on the host (:code:`.jpeg`)
194+
- :ref:`Video Encoded Frame Type` - Demonstrates how to view frame type when using video encoding
194195

195196
.. rubric:: Warp
196197

0 commit comments

Comments
 (0)