L4T Multimedia API Reference

27.1 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nvee_video_cuda_enc_guide.md
Go to the documentation of this file.
1 Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.
2 
3 @page nvee_video_cuda_enc_group Video CUDA Encoder Sample
4 @{
5 
6  - [Overview](#overview)
7  - [Key Structure and Classes](#key)
8 
9 - - - - - - - - - - - - - - -
10 <a name="overview">
11 ## Overview ##
12 
13 The Video CUDA Encoder sample demonstrates how to capture use libv4l2 API to encode
14 H.264/H.265 video streams. It starts using CUDA API before encoding to render a
15 black rectangle on the input YUV image data; the same buffer is used and shared by
16 the decode component.
17 
18 ![](nvee_video_cuda_enc.jpg)
19 
20 The `NvEGLImageFromFd` NV-defined API returns an EGLImage pointer
21 from the file descriptor buffer that is allocated by Tegra. CUDA then uses
22 EGLImage buffer to render the rectangle. The buffer then performs the video encode
23 operation and encodes it to either an H.264 or H.265 video stream.
24 
25 #### Prerequisites ####
26 Before running the sample, you must have the following:
27 
28 * README that provides details on the environment requirements to build and run the sample
29 
30 - - - - - - - - - - - - - - -
31 <a name="key">
32 ## Key Structure and Classes ##
33 
34 The `struct context_t` global structure manages all of the resources in the application.
35 
36 | %NvVideoConverter | Description |
37 | ---------------- | ----------- |
38 | class [NvVideoEncoder](classNvVideoEncoder.html) | This class contains all video encode related elements and functions. |
39 | EGLImageHKR | Specifies the EGLImage used for CUDA processing. |
40 
41 The [NvVideoConverter](classNvVideoConverter.html) class packages all video converting related elements and functions. The
42 sample uses the following key members:
43 
44 | %NvVideoConverter | Description |
45 | ---------------- | ----------- |
46 | [output_plane](classNvV4l2Element.html#aaba251827cef1b23e7c42f776e95fee5) | Specifies the output plane. |
47 | [capture_plane](classNvV4l2Element.html#a91806d7ed13b4b2c48758e8a02f46c6d) | Specifies the capture plane. |
48 | [createVideoEncoder](classNvVideoEncoder.html#aabb707f9188805ab7f097f82b3648351) | Static function to create video encode object. |
49 | [setExtControls](classNvV4l2Element.html#aaec1f40b777bb98870f18766690d7984) | Sets external control to V4l2 device. |
50 | setOutputPlaneFormat | Sets the output plane format. |
51 | setCapturePlaneFormat | Sets the capture plane format. |
52 | [isInError](classNvElement.html#a3ecd42c9dda2cec9506cf2ea8fa021fe) | Checks if under error state. |
53 
54 Class %NvVideoEncoder contains two key elements: `output_plane` and `capture_plane`. These objects
55 are derived from class type [NvV4l2ElementPlane](group__ee__nvv4lelementplane__group.html). The sample uses the following key members:
56 
57 | %NvV4l2ElementPlane | Description |
58 | ---------------- | ----------- |
59 | [setupPlane](classNvV4l2ElementPlane.html#a89959f455e5222f686187cc826b1b345) | Sets up the plane of V4l2 element. |
60 | [deinitPlane](classNvV4l2ElementPlane.html#af89cfe87d8f818beb0478bcf5b72574c) | Destroys the plane of V4l2 element. |
61 | [setStreamStatus](classNvV4l2ElementPlane.html#a03164dde4d7ab41f3e92b41e13059316) | Starts/stops the stream. |
62 | [setDQThreadCallback](classNvV4l2ElementPlane.html#a37f213325e0e4857180f5b2319317d6a) | Sets the callback function of dqueue buffer thread. |
63 | [startDQThread](classNvV4l2ElementPlane.html#a31f77f5e5ed1f320caa44a868a7cbedd) | Starts the thread of dqueue buffer. |
64 | [stopDQThread](classNvV4l2ElementPlane.html#aa798d14493de321fa90aeab6d944ca87) | Stops the thread of dqueue buffer. |
65 | [qBuffer](classNvV4l2ElementPlane.html#af4d52964fcfd37082f47682e457f5e95) | Queues the V4l2 buffer. |
66 | [dqBuffer](classNvV4l2ElementPlane.html#a8dfcbc666ee6f36a02abfb1170ae05cd) | Dqueues V4l2 buffer. |
67 | [getNumBuffers](classNvV4l2ElementPlane.html#ac5cd394a7e0a4afd69395759aeac8787) | Gets the number of V4l2 buffers. |
68 | [getNthBuffer](classNvV4l2ElementPlane.html#a868d438908f3d267dd4af1033133892f) | Gets the nth V4l2 buffer. |
69 
70 Two global functions are used to create and destroy EGLImage from the dmabuf file descriptor:
71 
72 | Global Function | Description |
73 | ---------------- | ----------- |
74 | NvEGLImageFromFd | Creates an EGLImage from dmabuf fd. |
75 | NvDestroyEGLImage | Destroys the EGLImage. |
76 
77 
78 @}
79 
Defines a helper class for operations performed on a V4L2 Element plane.
Defines a helper class for V4L2 Video Encoder.
EGLImageKHR NvEGLImageFromFd(EGLDisplay display, int dmabuf_fd)
This method must be used for getting EGLImage from dmabuf-fd.
Defines a helper class for V4L2 Video Converter.
int NvDestroyEGLImage(EGLDisplay display, EGLImageKHR eglImage)
This method must be used for destroying EGLImage object.