L4T Multimedia API Reference

32.3.1 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
multimedia_api/ll_samples/docs/l4t_mm_encoder_unit_sample.md
Go to the documentation of this file.
1 Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
2 
3 @page l4t_mm_encoder_unit_sample_group encode_sample
4 @{
5 
6  - [Overview](#overview)
7  - [Building and Running](#build_and_run)
8  - [Flow](#flow)
9  - [Key Structure and Classes](#key)
10 
11 
12 - - - - - - - - - - - - - - -
13 <a name="overview">
14 ## Overview ##
15 
16 The encode_sample application is a unit level implementation that
17 demonstrates how to encode H.264 video streams.
18 
19 The application reads YUV input buffers from a file, performs H.264
20 video encoding,
21 and saves the encoded bitstream to an elementary `.264` file.
22 
23 The application runs on file source simulated input buffers, and so does not
24 require a camera.
25 
26 Supported video formats are:
27 * H.264
28 
29 
30 <a name="build_and_run">
31 - - - - - - - - - - - - - - -
32 ## Building and Running ##
33 
34 ### Prerequisites
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.
38 
39 ### To build
40 * Enter:
41 
42  $ cd $HOME/multimedia_api/samples/unittest_samples/encoder_unit_sample
43  $ make
44 
45 ### To run
46 * Enter:
47 
48  $ ./encode_sample <in-file> <in-width> <in-height> <out-file>
49 
50 ### Example
51 
52  $ ./encode_sample ../../data/Video/sample_outdoor_car_1080p_10fps.yuv 1920 1080 sample_outdoor_car_1080p_10fps.h264
53 
54 
55 <a name="flow">
56 - - - - - - - - - - - - - - -
57 ## Flow
58 The following steps show the flow through this sample.
59 
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
67  in bitstream format.
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 @Capture @Plane it supports MMAP memory type.
71 
72 <a name="key">
73 - - - - - - - - - - - - - - -
74 ## Key Structure and Classes ##
75 
76 The sample uses the following key class:
77 
78 | Element | Description |
79 | ---------------- | ----------- |
80 | Buffer | Class modeled on v4l2_buffer structure. |
81 
82 The key structures and functions used in the sample are:
83 
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. |
96 
97 @}