Jetson Linux Multimedia API Reference

32.4.3 Release

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