Gstreamer: H264 encoder V4L2 provided buffer has bytesused 0 Crashing Error

Hey,

Getting this error and then stops encoding:

0:00:03.404924665 20620 0x72102a30 WARN v4l2allocator gstv4l2allocator.c:1372:gst_v4l2_allocator_dqbuf:x264enc:pool:src:allocator V4L2 provided buffer has bytesused 0 which is too small to include data_offset 0

0:00:01.078745802 e[335m13858e[00m 0x71905c30 e[33;01mLOG    e[00m e[00m       v4l2allocator gstv4l2allocator.c:1333:gst_v4l2_allocator_dqbuf:<x264enc:pool:src:allocator>e[00m dequeued buffer 1 (flags 0x4001)
    0:00:01.078766427 e[335m13858e[00m   0x9bd2f0 e[37mDEBUG  e[00m e[00;01;31;44m            GST_PADS gstpad.c:4077:gst_pad_query:<srtsink0:sink>e[00m sent query 0x72b08090 (caps), result 1
    0:00:01.078780437 e[335m13858e[00m 0x71905c30 e[33;01mLOG    e[00m e[00m       v4l2allocator gstv4l2allocator.c:1362:gst_v4l2_allocator_dqbuf:<x264enc:pool:src:allocator>e[00m Dequeued capture buffer, length: 524288 bytesused: 0 data_offset: 0
    0:00:01.078816114 e[335m13858e[00m   0x9bd2f0 e[37mDEBUG  e[00m e[00;04m             default gstutils.c:2769:query_caps_func:<queue3:src>e[00m intersect with result application/x-rtp, media=(string)video, payload=(int)[ 96, 127 ], clock-rate=(int)90000, encoding-name=(string)H264
    0:00:01.078839499 e[335m13858e[00m 0x71905c30 e[33;01mWARN   e[00m e[00m       v4l2allocator gstv4l2allocator.c:1372:gst_v4l2_allocator_dqbuf:<x264enc:pool:src:allocator>e[00m V4L2 provided buffer has bytesused 0 which is too small to include data_offset 0
    0:00:01.078877364 e[335m13858e[00m   0x9bd2f0 e[37mDEBUG  e[00m e[00;04m             default gstutils.c:2771:query_caps_func:<queue3:src>e[00m intersected application/x-rtp, media=(string)video, payload=(int)[ 96, 127 ], clock-rate=(int)90000, encoding-name=(string)H264
    0:00:01.078934707 e[335m13858e[00m 0x71905c30 e[33;01mLOG    e[00m e[00m      v4l2bufferpool gstv4l2bufferpool.c:1260:gst_v4l2_buffer_pool_dqbuf:<x264enc:pool:src>e[00m dequeued buffer 0x71817e90 seq:0 (ix=1), mem 0x71902058 used 0, plane=0, flags 00004001, ts 0:00:00.185658000, pool-queued=3, buffer=0x71817e90
    0:00:01.078951374 e[335m13858e[00m   0x9bd2f0 e[37mDEBUG  e[00m e[00;01;31;44m            GST_PADS gstpad.c:3438:gst_pad_query_default:<queue3:sink>e[00m not forwarding 0x72b08090 (caps) query
    0:00:01.078965801 e[335m13858e[00m 0x71905c30 e[37mDEBUG  e[00m e[00m      v4l2bufferpool gstv4l2bufferpool.c:1464:gst_v4l2_buffer_pool_release_buffer:<x264enc:pool:src>e[00m release buffer 0x71817e90
    0:00:01.078991946 e[335m13858e[00m   0x9bd2f0 e[37mDEBUG  e[00m e[00;01;31;44m            GST_PADS gstpad.c:4077:gst_pad_query:<queue3:sink>e[00m sent query 0x72b08090 (caps), result 1
    0:00:01.079043404 e[335m13858e[00m 0x71905c30 e[33;01mLOG    e[00m e[00m      v4l2bufferpool gstv4l2bufferpool.c:1147:gst_v4l2_buffer_pool_qbuf:<x264enc:pool:src>e[00m queuing buffer 1
    0:00:01.079044863 e[335m13858e[00m   0x9bd2f0 e[37mDEBUG  e[00m e[00;01;34m            GST_CAPS gstutils.c:3111:gst_pad_peer_query_caps:<rtp:src>e[00m peer query returned application/x-rtp, media=(string)video, payload=(int)[ 96, 127 ], clock-rate=(int)90000, encoding-name=(string)H264
    0:00:01.079116841 e[335m13858e[00m   0x9bd2f0 e[37mDEBUG  e[00m e[00;01;37;41m     GST_PERFORMANCE gstcaps.c:178:_gst_caps_copy:e[00m doing copy 0x9b2e50 -> 0x72b09a50
    0:00:01.079148143 e[335m13858e[00m 0x71905c30 e[33;01mLOG    e[00m e[00m       v4l2allocator gstv4l2allocator.c:1286:gst_v4l2_allocator_qbuf:<x264enc:pool:src:allocator>e[00m queued buffer 1 (flags 0x4003)
    0:00:01.079158872 e[335m13858e[00m   0x9bd2f0 e[37mDEBUG  e[00m e[00;01;37;41m     GST_PERFORMANCE gstminiobject.c:428:gst_mini_object_make_writable:e[00m copy GstCaps miniobject 0x9b2e50 -> 0x72b09a50
    0:00:01.079179393 e[335m13858e[00m 0x71905c30 e[37mDEBUG  e[00m e[00m      v4l2bufferpool gstv4l2bufferpool.c:2073:gst_v4l2_buffer_pool_process:<x264enc:pool:src>e[00m end of stream reached

Would you please provide the SW information and the pipeline you used for more investigation?

Hey

Version: 1.16.2
The command was

gst-launch-1.0 v4l2src device=/dev/video0 do-timestamp=true name=video ! video/x-raw,framerate=30/1,width=720,height=480 ! queue ! nvv4l2h264enc control-rate=1 bitrate=5000000 name=x264enc ! queue ! rtph264pay name=rtp config-interval=-1 ! queue ! udpsink host=[IP REDACTED] port=5004 sync=false

From debugging it looks like it crashing when it changes the buffer size to 0.
When adding code in gstv4l2allocator.c to bypass changing the buffer size if the used size is 0 it stops crashing and carriers on outputting as normal but then hit with unlimited amount of

v4l2 provided buffer that is too big for the memory

Which its saying used size is multiple gigabytes and the output is corrupted

Hi,
Please check if these patches help:

Or you may consider to use default 1.14.5. It is verified with our SQA tests and should be stable.