NvVideoEncoder output_plane color format question

Hi,

Does NvVideoEncoder support NV12 colorformat?

I saw in the thread TX2 tegra_multimedia_api encode/decode issue, it is supported.

But I got “Only YUV420M, YUV444M and P010M are supported” message when using V4L2_PIX_FMT_NV12M.

Have a check below doc. Looks like only jpeg not support NV12

https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide%2Fsoftware_features_jetson_xavier.html%23wwpID0E6HA

Hi,
Please apply the patch and give it a try.

diff --git a/multimedia_api/ll_samples/samples/common/classes/NvVideoEncoder.cpp b/multimedia_api/ll_samples/samples/common/classes/NvVideoEncoder.cpp
index f2c3ba7..fda62b8 100644
--- a/multimedia_api/ll_samples/samples/common/classes/NvVideoEncoder.cpp
+++ b/multimedia_api/ll_samples/samples/common/classes/NvVideoEncoder.cpp
@@ -100,10 +100,10 @@ NvVideoEncoder::setOutputPlaneFormat(uint32_t pixfmt, uint32_t width,
     uint32_t num_bufferplanes;
     NvBuffer::NvBufferPlaneFormat planefmts[MAX_PLANES];
 
-    if (pixfmt != V4L2_PIX_FMT_YUV420M && pixfmt != V4L2_PIX_FMT_YUV444M &&
-        pixfmt != V4L2_PIX_FMT_P010M)
+    if (pixfmt != V4L2_PIX_FMT_YUV420M && pixfmt != V4L2_PIX_FMT_NV12M &&
+        pixfmt != V4L2_PIX_FMT_YUV444M && pixfmt != V4L2_PIX_FMT_P010M)
     {
-        COMP_ERROR_MSG("Only YUV420M, YUV444M and P010M are supported");
+        COMP_ERROR_MSG("Only YUV420M, NV12M, YUV444M and P010M are supported");
         return -1;
     }

Hi DaneLLL,

I applied this patch to NvVideoEncoder.cpp.
And I tried two cases:

  1. In 01_video_encode/video_encode_main.cpp, changes nothing, leaves:
    ctx.raw_pixfmt = V4L2_PIX_FMT_YUV420M;
    cParams.colorFormat = NvBufferColorFormat_YUV420;
  2. In 01_video_encode/video_encode_main.cpp, changes to:
    ctx.raw_pixfmt = V4L2_PIX_FMT_NV12M;
    cParams.colorFormat = NvBufferColorFormat_NV12;

Both results from the two cases have wrong color space values.

Am I using it right? Or is there anything else I should configure?

Hi,
You should need to modify read_video_frame() to read NV12 frames.

Thanks DaneLLL.