Hi!
I’m trying to get lossless hardware H.264 encoding working on a Xavier flashed from JetPack 4.1. I downloaded the Tegra Multimedia API and compiled sample “01_video_encode” and ran some raw YUV data through it with the --elossless option. However, when I run a binary comparison, the outputs are not the same. I tried looking at several frames in the encoded YUV output and they all had very noticeable compression artifacts.
The following are the GStreamer pipelines I used to run my tests:
# Get some frames from the camera and save them in raw YUV format
gst-launch-1.0 -e tcambin ! 'video/x-raw, width=(int)1440, height=(int)1080, framerate=(fraction)30/1' \
! videoconvert ! "video/x-raw,format=I420" ! filesink location=~/Desktop/original.yuv
# Run the raw YUV from the camera through the hardware encoder, with lossless enabled
./video_encode ~/Desktop/original.yuv 1440 1080 H264 ~/Desktop/encoded.h264 --elossless
# Decode the encoded H.264 and dump it back to the disk
gst-launch-1.0 -e filesrc location=~/Desktop/encoded.h264 ! "video/x-h264, stream-format=(string)byte-stream" \
! h264parse ! omxh264dec ! nvvidconv ! "video/x-raw,format=I420" ! filesink location=~/Desktop/encoded.yuv
Then, for each YUV frame from the original and encoded file, I loaded their luma components and performed a binary comparison between them with OpenCV. The compression artifacts are pretty obvious, both in the binary difference and just by examining the luma of the encoded image.
As a last ditch effort, I also tried running a command I’ve seen in a few threads of other people trying the same thing (see here: https://devtalk.nvidia.com/default/topic/1026493/jetson-tx1/lossless-h-264-encoding/) that takes the raw YUV as an input, encodes it losslessly, immediately decodes it, and outputs it to a file:
gst-launch-1.0 -e filesrc location=~/Desktop/original.yuv blocksize=2332800 ! \
"video/x-raw,width=(int)1440,height=(int)1080,framerate=(fraction)30/1,format=I420" ! \
omxh264enc control-rate=0 qp-range=0,1:0,1:0,1 quant-i-frames=0 quant-p-frames=0 ! \
h264parse ! omxh264dec ! nvvidconv ! "video/x-raw,format=I420" ! \
filesink location=~/Desktop/encoded.yuv
This produces similar compression artifacts.
Am I missing something?
Thanks!