How to convert a YUV file to BGR format without Alpha channel

Hi, I’m a new GPU engineer and I got a demand to convert a YUV file.

As the title said, i didn’t find a API to convert a YUV file to BGR format without Alpha channel, it seems that NvVideoConverter doesn’t support 3-byte BGR format. So what should I do to meet my demand efficiently?

This is a similar API I found:
https://docs.nvidia.com/jetson/l4t-multimedia/classNvVideoConverter.html#a2c7ea36f2ec861d546fe779f2ab77fe0

Thank you for answers!

You may use gstreamer for that. For example, assuming your YUV file is 1920x1080@30fps in NV12 format, you would use this pipeline for converting:

gst-launch-1.0 filesrc location=test.NV12 ! videoparse format=23 width=1920 height=1080 framerate=30/1 ! videoconvert ! video/x-raw,format=RGB ! filesink location=test.RGB

# See this command output for other format codes
gst-inspect-1.0 videoparse

Gstreamer is good to convert but can’t meet my demand.
I’m asked to convert a frame of YUV422 data to a 3-channel BGR format in high frequency.
I wonder that if there is an api to do so instead of coding CUDA by myself.

Hi,
You may refer to tegra_multimedia_api\samples\04_video_dec_trt
It converts decoded YUV420 to RGBA through NvBufferTransform(), and then re-sample into BGR/RGB planes through convertEglFrameIntToFloat().

For your usecase, you can replace ‘decoded YUV420’ with your YUV422 source.

Hardware VIC engine does not support 3-byte BGR, so we utilize CUDA programming to eliminate alpha planes.