Lossless H.264 encoding

Hi all,

I already found old topic which cover this topic here: https://devtalk.nvidia.com/default/topic/991417/

There I found that lossless encoding was not supported on Jetson TX1 for software version r24.2.1 but it will be provided in next releases. I try to achieve this with current release r28.1 using gstreamer and opencv but it seems to ignore qp-rang parameters:

appsrc ! nvvidconv ! video/x-raw(memory:NVMM), format=(string)I420  ! omxh264enc preset-level=3 profile=4 control-rate=2 qp-range=0,0:0,0:0,0   ! video/x-h264, stream-format=(string)byte-stream ! h264parse ! flvmux ! filesink location=test.flv

So I would like to ask if there is problem with my code or lossless compression is still not available?

Best regards!

Hi,
Please try

$ gst-launch-1.0 nvcamerasrc num-buffers=150 ! omxh264enc control-rate=0 qp-range=0,1:0,1:0,1 quant-i-frames=0 quant-p-frames=0 ! 'video/x-h264,stream-format=byte-stream' ! filesink location=a.h264

Hi Dane,

I try to change parameters with your suggest and we achieve very high quality but not lossless. We have still few bits in wrong values but for our purpose we can live with that. I go another issue about hangs and segmentation fault using gstreamer:

  • 640x360 gryscale - we can use quantization parameters 0 no problem
  • 1280x720 gryscale - after about 20 captured frames we get segmentation fault and also ERROR: OMX Buffer too small
  • 640x360 color - we can use quantization parameters 3 without problem
  • 640x360 color - after about 20 captured frames we get segmentation fault and also ERROR: OMX Buffer too small
  • 1280x720 gryscale - with default quantization parameters goes without problem

Is there any limitation about how high quality and with which resolution we can achieve?

P.S. We are using v4l2 for capturing USB cam -> opencv (3.3 compiled vs gstreamer) to process it -> gstreamer to save data.

Best regards,
Zolnierczyk Piotr

Hi zolnierczyk,

We try 640x360 and 1280x720 color are works without ERROR.

$ gst-launch-1.0 nvcamerasrc num-buffers=20 ! omxh264enc control-rate=0 qp-range=0,1:0,1:0,1 quant-i-frames=0 quant-p-frames=0 ! 'video/x-h264,stream-format=byte-stream, width=(int)640, height=(int)360' ! filesink location=a.h264

But when we run gryscale, got below error:

$ gst-launch-1.0 nvcamerasrc num-buffers=150 ! nvvidconv ! 'video/x-raw(memory:NVMM),format=GRAY8,width=(int)1280, height=(int)720' ! omxh264enc control-rate=0 qp-range=0,1:0,1:0,1 quant-i-frames=0 quant-p-frames=0 ! 'video/x-h264,stream-format=byte-stream' ! filesink location=g.h264
WARNING: erroneous pipeline: could not link nvvconv0 to omxh264enc-omxh264enc0

The omxh264enc support I420 and NV12 format. How do you run the format=GRAY8?

Thanks!

Hi zolnierczyk,

Have you clarified and resolve the problem?
Any update?

Thanks

We are using opencv compiled with gstreamer as library to write data so we are not using nvcamerasrc. In opencv pipeline I define frame to save as GRAY8 and this is send to nvvidconv. Propably nvvidconv conver it to normal RGB frame and as is is later pushed to omxh264enc. You can use gst-inspect-1.0 tool to check what format omxh264enc can support but from what I remember it can only have as source YUV or RGB format.

We decide to move to more powerful platform (we are experimenting also with DrivePX) because we will try to maintain multiple lossless FULL HD stream and TX1 seems to not be able to handle so much.

Best regards!