YUV values after decoding using nvv4l2decoder

I am using Jetson Xavier. I am decoding an .mp4 file using nvv4l2decoder. I wanna manipulate the Y,U,V values of each frame. Is it possible to do that ? If yes, how to do it ?

It may depend on the mp4 file content, but for H264,H265,… I’d guess that if format is supported, nvv4l2decoder would output NV12 format into NVMM memory.

You may further tell what kind of processing you intend to do. If it is a filter that can be implemented on GPU (cuda, opencv-cuda, …) you may have a look to nvivafilter plugin such as here.

All i want to do is increase the Y value that increases the luminance of the video and encode it back. I want a full control over the pixels of each frame. What would be a better approach to do the same ?

nvivafilter is a good choice for this. You would download public sources for your L4T release, extract nvivafilter sources, and build your custom library that will be used by nvivafilter.

You can also have a look to various examples using opencv-CUDA (you may have to build and install opencv with CUDA support) such as:
How to perform fish-eye lens distortion correction in gstreamer pipeline? (Hfov ~150) - #16 by Honey_Patouceul (using RGBA).

For your case you would use NV12 format in NVMM memory as output caps of nvivafilter so that you’ll get the Y plane The example I mentioned above should give enough for modifying Y plane with opencv-cuda. (Note that there may be stride alignment with YUV).

gst-launch-1.0 -v uridecodebin uri=file:///<your_path_to_mp4_file> ! nvvidconv ! 'video/x-raw(memory:NVMM)' ! nvivafilter customer-lib-name=./lib-gst-custom-opencv_cudaprocess.so cuda-process=true ! 'video/x-raw(memory:NVMM), format=NV12' ! autovideosink 

Note that this commands assumes it is run in the directory where your custom lib lib-gst-custom-opencv_cudaprocess.so is. Also note that if your custom lib is not found, nvivafilter will use its default version (doing nothing as gpu-process).

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.