Bad file descriptor from nvv4l2decoder

Hi! I use two gstreamer pipeline for cutting some part of video file:

filesrc location=*.mkv ! matroskademux name=demuxer demuxer.video_0 ! nvv4l2decoder ! appsink name=sink emit-signals=true

appsrc name=src format=GST_FORMAT_TIME block=FALSE is-live=TRUE ! videoconvert ! nvvidconv ! "video/x-raw(memory:NVMM), format=(string)NV12" ! nvv4l2h265enc maxperf-enable=1 control-rate=0 bitrate=8000000 ! video/x-h265, stream-format=byte-stream ! h265parse ! mp4mux ! filesink location=out.mp4 sync=false

After starting first pipeline I will seek to needed timepoint, pull needed capacity of samples from appsink and push it to appsrc of second pipeline. After that I close input pipeline and set new eos for second pipeline and close it too

    gst_element_set_state(input_pipeline_, GST_STATE_NULL);

    gst_app_src_end_of_stream(GST_APP_SRC(src));
    if (GstMessage *msg = gst_bus_timed_pop_filtered(output_bus_, GST_CLOCK_TIME_NONE,
                                                     GstMessageType(GST_MESSAGE_EOS | GST_MESSAGE_ERROR))) {
        handleGstMessage(msg);
    }
    gst_element_set_state(output_pipeline_, GST_STATE_NULL);

Looks like all works fine, but if I set GST_DEBUG=1 then I see the errors after closing second pipeline:

0:00:02.247638405 [335m 9880[00m   0x7ec0002b20 [31;01mERROR  [00m [00m       v4l2allocator gstv4l2allocator.c:1373:gst_v4l2_allocator_qbuf:<nvv4l2decoder0:pool:src:allocator>[00m failed queueing buffer 7: Bad file descriptor
0:00:02.247771721 [335m 9880[00m   0x7ec0002b20 [31;01mERROR  [00m [00m      v4l2bufferpool gstv4l2bufferpool.c:1396:gst_v4l2_buffer_pool_qbuf:<nvv4l2decoder0:pool:src>[00m could not queue a buffer 7
0:00:02.253656369 [335m 9880[00m   0x7ec0002b20 [31;01mERROR  [00m [00m       v4l2allocator gstv4l2allocator.c:1373:gst_v4l2_allocator_qbuf:<nvv4l2decoder0:pool:src:allocator>[00m failed queueing buffer 8: Bad file descriptor
0:00:02.253873016 [335m 9880[00m   0x7ec0002b20 [31;01mERROR  [00m [00m      v4l2bufferpool gstv4l2bufferpool.c:1396:gst_v4l2_buffer_pool_qbuf:<nvv4l2decoder0:pool:src>[00m could not queue a buffer 8

What it means? And why it happens?

Not sure what your mkv files hold. I would expect some H264/H265/VP8/VP9/MJPG files for video.
However, your first part pipeline has no type checker… I may be wrong, feel free to correct me.

Without knowing the encoding, I would use decodebin, but this may be the source of the issue:

# This shows the error
GST_DEBUG=*:3 gst-launch-1.0  filesrc location= ~/Videos/dolbycanyon.mkv ! matroskademux name=demuxer demuxer.video_0 ! decodebin ! nvvidconv ! appsink emit-signals=true
# Number of messages may be related to appsink's max-buffers number. You may try fakesink instead for checking.
# Specifying caps video/x-raw before appsink I don't see these anymore
GST_DEBUG=*:3 gst-launch-1.0  filesrc location= ~/Videos/dolbycanyon.mkv ! matroskademux name=demuxer    demuxer.video_0 ! decodebin ! nvvidconv ! video/x-raw ! appsink emit-signals=true
1 Like

@Honey_Patouceul thank for quick answer. Yes, you are right, after I add to pipeline nvvidconv ! video/x-raw I don’t see the errors anymore

@Honey_Patouceul but how appsink handles this samples without nvvidconv ! video/x-raw? If I’m right, without it we send to appsink DMA buffer, but how it can be handled?

Without nvvidconv, you would have NVMM memory buffers. You may handle these from app, but would have to copy into CPU memory anyway for using videoconvert downstream.

so, in other way, I can just remove videoconvert element from output pipeline, right?

It shouldn’t be harmful to try ;-)

Yes, but you may need nvvidconv for copying into NVMM memory for encoding with nvv4l2h265enc.
Alternatetively, you may use omxh265enc that may be able to run from standard CPU memory (however OMX plugins are going deprecated on Jetson).

for example the pipelines

filesrc location=*.mkv ! matroskademux name=demuxer demuxer.video_0 ! nvv4l2decoder ! nvvidconv ! "video/x-raw(memory:NVMM)" ! appsink name=sink emit-signals=true

appsrc name=src format=GST_FORMAT_TIME block=FALSE is-live=TRUE ! nvvidconv ! "video/x-raw(memory:NVMM), format=(string)NV12" ! nvv4l2h265enc maxperf-enable=1 control-rate=0 bitrate=8000000 ! video/x-h265, stream-format=byte-stream ! h265parse ! mp4mux ! filesink location=out.mp4 sync=false

right?