1 Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
3 @page l4t_mm_encoder_unit_sample_group encode_sample
6 - [Overview](#overview)
7 - [Building and Running](#build_and_run)
9 - [Key Structure and Classes](#key)
12 - - - - - - - - - - - - - - -
16 The encode_sample application is a unit level implementation that
17 demonstrates how to encode H.264 video streams.
19 The application reads YUV input buffers from a file, performs H.264
21 and saves the encoded bitstream to an elementary `.264` file.
23 The application runs on file source simulated input buffers, and so does not
26 Supported video formats are:
30 <a name=
"build_and_run">
31 - - - - - - - - - - - - - - -
32 ## Building and Running ##
35 * You have followed steps 1-3 in @ref mmapi_build.
36 * If you are building from your host Linux PC (x86), you have followed
37 step 4 in @ref mmapi_build.
42 $ cd $HOME/multimedia_api/samples/unittest_samples/encoder_unit_sample
48 $ ./encode_sample <in-file> <in-width> <in-height> <out-file>
52 $ ./encode_sample ../../data/Video/sample_outdoor_car_1080p_10fps.yuv 1920 1080 sample_outdoor_car_1080p_10fps.h264
56 - - - - - - - - - - - - - - -
58 The following steps show the flow through
this sample.
60 -# The encoder instance is created.
61 -# V4L2_EVENT_EOS is subscribed.
62 -# @b Output @b Plane and @b Capture @b Plane are set up.
63 -# External controls are set.
64 -# The @b Output @b Plane receives input in YUV frame format and delivers it
65 to the @b Encoder
for encoding.
66 -# The @b Capture @b Plane transfers encoded frames to the application
68 -# The encoded bitstream is written to a file.
69 -# For the @b Output @b Plane the application supports MMAP
70 memory type. For the @b Capture @b Plane it supports MMAP memory type.
73 - - - - - - - - - - - - - - -
74 ## Key Structure and Classes ##
76 The sample uses the following key
class:
78 | Element | Description |
79 | ---------------- | ----------- |
80 | Buffer | Class modeled on v4l2_buffer structure. |
82 The key structures and functions used in the sample are:
84 | Function | Description |
85 | ---------------- | ----------- |
86 | encoder_process_blocking | Function loop to DQ and EnQ buffers on output plane till eos is signalled. |
87 | dq_buffer | Function to dequeue a buffer from the plane. |
88 | capture_plane_callback | Callback
function when enc_cap_thread is created. |
89 | q_buffer | Function to queue a buffer on the plane. |
90 | req_buffers_on_capture_plane | Function to request
for buffers on the encoder capture plane. |
91 | req_buffers_on_output_plane | Function to request
for buffers on the encoder output plane. |
92 | set_capture_plane_format | Function to set the format on the encoder capture plane. |
93 | set_output_plane_format | Function to set the format on the encoder output plane. |
94 | set_ext_controls | Function to set the value of controls. |
95 | subscribe_event | Function to subscrive to a V4L2
event. |