Using YUV444 for encoding

I am using Jetson MMAPI encoder sample, it works fine with YUV420 types of images. The problem is that the original images are RGB and when I convert them to yuv420, since the u,v channels are half-size we lose some part of the color information which doesn’t allow us to retrieve all the original image information after decoding.
I tired this settings to work with yuv444 but I get a greenish frame in the video file. The image structure looks fine (so I guess the y channel is fine) but it is like a green-scale image:

I am doing everythin in 8bit scale by the way.

    ctx->cs = V4L2_COLORSPACE_BT2020;
    ctx->raw_pixfmt = V4L2_PIX_FMT_YUV444M;
    ctx->encoder_pixfmt = V4L2_PIX_FMT_H265;
    ctx->output_memory_type = V4L2_MEMORY_DMABUF;
    ctx->profile = V4L2_MPEG_VIDEO_H265_PROFILE_MAIN;
    ctx->ratecontrol = V4L2_MPEG_VIDEO_BITRATE_MODE_VBR;
    ctx->level =  V4L2_MPEG_VIDEO_H265_LEVEL_6_2_HIGH_TIER;

Is there a way to exploit 444 format or keep the color information somehow?

Hi,
YUV444 encoding is demonstrated in 01_video_encode sample. Please take a look. And please refer to the posts:
Can not decode H265 lossless - #3 by DaneLLL
Can tx2nx decode YUV444? - #3 by DaneLLL

I am using a similar approach as 01 sample with similar settings, and the video is made, however the image looks greenish. My original frames are RGB so I use this conversion, to make them yuv444:

I tried other colorspaces (V4L2_COLORSPACE_BT2020, V4L2_COLORSPACE_RAW, V4L2_COLORSPACE_SMPTE170M, V4L2_COLORSPACE_REC709) but still the same result comes up.

This is the original image:

And this is the frame after encoding:

Hi,
The issue looks to be in conversion. Would use this YUV data:

$ gst-launch-1.0 videotestsrc num-buffers=150 !  'video/x-raw, width=(int)1280, height=(int)720, format=(string)Y444'  ! filesink location=~/origin.yuv

As input to your application. To confirm the encoding part is good in the application.

@DaneLLL
Thank you for the suggestion.
Using the gstreamer command I made a video with an arbitrary size. When I extract the the frames of origin.yuv using ffmpeg, the frames look like this:


.

And when I feed origin.yuv into the encoder (without any change), the video frames after encoding look like this:

So I guess we can say it is not the color conversion problem and probably something is wrong with the encoder’s settings, but I have not clue of that.

Hi,
Please run 01_video_encode sample to compress the YUV and check if the issue is present. If there is no issue when running 01_video_encode, it looks to be an issue in the application.

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