L4T Multimedia API Reference

32.2 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
multimedia_api/ll_samples/docs/l4t_mm_01_video_encode.md
Go to the documentation of this file.
1 Copyright (c) 2014-2019, NVIDIA CORPORATION. All rights reserved.
2 
3 @page l4t_mm_01_video_encode_group 01_video_encode
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 video_encode sample application demonstrates how to encode H.264/H.265
17 video streams.
18 
19 The application YUV reads input buffers from a file, performs H.264 or H.265
20 video encoding,
21 and saves the encoded bitstream to an elementary `.264` or `.265` 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 * H.265
29 
30 
31 <a name="build_and_run">
32 - - - - - - - - - - - - - - -
33 ## Building and Running ##
34 
35 ### Prerequisites
36 * You have followed steps 1-3 in @ref mmapi_build.
37 * If you are building from your host Linux PC (x86), you have followed
38  step 4 in @ref mmapi_build.
39 
40 ### To build
41 * Enter:
42 
43  $ cd $HOME/multimedia_api/samples/01_video_encode
44  $ make
45 
46 ### To run
47 * Enter:
48 
49  $ video_encode <in-file> <in-width> <in-height> <encoder-type> <out-file> [OPTIONS]
50 
51 ### To view supported options
52 Enter:
53 
54  $ ./video_encode --help
55 
56 ### Example
57 
58  $ ./video_encode ../../data/Video/sample_outdoor_car_1080p_10fps.yuv 1920 1080 H264 sample_outdoor_car_1080p_10fps.h264
59 
60 
61 <a name="flow">
62 - - - - - - - - - - - - - - -
63 ## Flow
64 The following diagram shows the flow through this sample.
65 
66 ![ ](l4t_mm_01_video_encode.png)
67 
68 * The @b Output @b Plane receives input in YUV frame format and delivers it
69  to the @b Encoder for decoding.
70 * The application transfers encoded frames to the @b Capture @b Plane
71  in bitstream format.
72 * The encoded bitstream is written to a file.
73 * For the @b Output @b Plane the application supports MMAP, DMABUF, and USRPTR
74  memory types. For the Capture Plane it supports MMAP memory type.
75 
76 <a name="key">
77 - - - - - - - - - - - - - - -
78 ## Key Structure and Classes ##
79 
80 The sample uses the following key structures and classes.
81 
82 | Element | Description |
83 | ---------------- | ----------- |
84 | [NvVideoEncoder](classNvVideoEncoder.html) | Contains all video encoding-related elements and functions. |
85 | Enc_pollthread | A pointer to the thread handler for the encoding capture loop. |
86 
87 The [NvVideoEncoder](classNvVideoEncoder.html) class packages all
88 video encoding-related elements and functions. Key members used in the sample
89 are:
90 
91 | Member | Description |
92 | ---------------- | ----------- |
93 | [output_plane](classNvV4l2Element.html#aaba251827cef1b23e7c42f776e95fee5) | Specifies the V4L2 output plane. |
94 | [capture_plane](classNvV4l2Element.html#a91806d7ed13b4b2c48758e8a02f46c6d) | Specifies the V4L2 capture plane. |
95 | [createVideoEncoder](classNvVideoEncoder.html#ad7cff71c0fe1f78cc332fed7c6b00eb3) | Static function to create video encode object. |
96 | [subscribeEvent](classNvV4l2Element.html#a7fd9f21268d5fdc979065b1b04b93220) | Subscribe event. |
97 | [setOutputPlaneFormat](l4t_mm_video_cuda_enc_group.html#NvVideoConverter::setOutputPlaneFormat) | Set output plane format. |
98 | [setCapturePlaneFormat](classNvElement.html#a3ecd42c9dda2cec9506cf2ea8fa021fe) | Set capture plane format. |
99 | [dqEvent](classNvV4l2Element.html#a9a8b5337356f82d04f5fbd7cce6e51e3) | Dqueue the event which reports by the V4L2 device. |
100 | [isInError](classNvElement.html#a3ecd42c9dda2cec9506cf2ea8fa021fe) | Checks if under error state. |
101 
102 Class %NvVideoEncoder contains two key elements: `output_plane`
103 and `capture_plane`. These objects are derived from class type
104 [NvV4l2ElementPlane](group__l4t_mm__nvv4lelementplane__group.html).
105 The sample uses the following key members:
106 
107 | Element | Description |
108 | ---------------- | ----------- |
109 | [setupPlane](classNvV4l2ElementPlane.html#a89959f455e5222f686187cc826b1b345) | Sets up the plane of V4L2 element. |
110 | [deinitPlane](classNvV4l2ElementPlane.html#af89cfe87d8f818beb0478bcf5b72574c) | Destroys the plane of the V4L2 element. |
111 | [setStreamStatus](classNvV4l2ElementPlane.html#a03164dde4d7ab41f3e92b41e13059316) | Starts/stops the stream. |
112 | [setDQThreadCallback](classNvV4l2ElementPlane.html#a37f213325e0e4857180f5b2319317d6a) | Sets the callback function of the dqueue buffer thread. |
113 | [startDQThread](classNvV4l2ElementPlane.html#a31f77f5e5ed1f320caa44a868a7cbedd) | Starts the thread of the dqueue buffer. |
114 | [stopDQThread](classNvV4l2ElementPlane.html#aa798d14493de321fa90aeab6d944ca87) | Stops the thread of the dqueue buffer. |
115 | [qBuffer](classNvV4l2ElementPlane.html#af4d52964fcfd37082f47682e457f5e95) | Queues the V4L2 buffer. |
116 | [dqBuffer](classNvV4l2ElementPlane.html#a8dfcbc666ee6f36a02abfb1170ae05cd) | Dequeues the V4L2 buffer. |
117 | [getNumBuffers](classNvV4l2ElementPlane.html#ac5cd394a7e0a4afd69395759aeac8787) | Gets the number of V4L2 buffers. |
118 | [getNumQueuedBuffers](classNvV4l2ElementPlane.html#abe813f1ac780689ea75207866fe12478) | Gets the number of buffers currently queued on the plane. |
119 
120 @}
Defines a helper class for operations performed on a V4L2 Element plane.
Defines a helper class for V4L2 Video Encoder.
int setOutputPlaneFormat(uint32_t pixfmt, uint32_t width, uint32_t height, enum v4l2_nv_buffer_layout type)
Sets the format on the converter output plane.