Occasionally nvv4l2h265enc drops the last frame

• Hardware Platform (Jetson / GPU)
GPU NVIDIA GeForce RTX 2080
• DeepStream Version
6.1.0
• JetPack Version (valid for Jetson only)
• TensorRT Version
• NVIDIA GPU Driver Version (valid for GPU only)
515.65.01
• Issue Type( questions, new requirements, bugs)
bug
• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing)

Occasionally nvv4l2h265enc drops the last frame.

Launch a pipeline to encode video with nvv4l2h265enc

gst-launch-1.0 \
    videotestsrc num-buffers=100 ! \
    nvvideoconvert ! \
    nvv4l2h265enc ! \
    filesink location=test.h265

and check the number of frames in test.h265

ffprobe -v error -select_streams v:0 -count_packets -show_entries stream=nb_read_packets -of csv=p=0 test.h265

Usually everything is fine and test.h265 contains 100 frames, but sometimes - 99 frames. It occurs once in a few hundreds runs.

Is there a configuration parameter for nvv4l2h265enc that prevents it to drop frames?

Are these warnings related to the issue?

Setting pipeline to PAUSED ...
0:00:00.045545144 115107 0x56023c5aea60 WARN                    v4l2 gstv4l2object.c:3056:gst_v4l2_object_get_nearest_size:<nvv4l2h265enc0:sink> Unable to try format: Unknown error -1
0:00:00.045559558 115107 0x56023c5aea60 WARN                    v4l2 gstv4l2object.c:2941:gst_v4l2_object_probe_caps_for_format:<nvv4l2h265enc0:sink> Could not probe minimum capture size for pixelformat YM12
0:00:00.045566372 115107 0x56023c5aea60 WARN                    v4l2 gstv4l2object.c:3056:gst_v4l2_object_get_nearest_size:<nvv4l2h265enc0:sink> Unable to try format: Unknown error -1
0:00:00.045572112 115107 0x56023c5aea60 WARN                    v4l2 gstv4l2object.c:2947:gst_v4l2_object_probe_caps_for_format:<nvv4l2h265enc0:sink> Could not probe maximum capture size for pixelformat YM12
0:00:00.045578891 115107 0x56023c5aea60 WARN                    v4l2 gstv4l2object.c:2394:gst_v4l2_object_add_interlace_mode:0x56023c59e830 Failed to determine interlace mode
0:00:00.045588998 115107 0x56023c5aea60 WARN                    v4l2 gstv4l2object.c:3056:gst_v4l2_object_get_nearest_size:<nvv4l2h265enc0:sink> Unable to try format: Unknown error -1
0:00:00.045594626 115107 0x56023c5aea60 WARN                    v4l2 gstv4l2object.c:2941:gst_v4l2_object_probe_caps_for_format:<nvv4l2h265enc0:sink> Could not probe minimum capture size for pixelformat NM12
0:00:00.045599203 115107 0x56023c5aea60 WARN                    v4l2 gstv4l2object.c:3056:gst_v4l2_object_get_nearest_size:<nvv4l2h265enc0:sink> Unable to try format: Unknown error -1
0:00:00.045604318 115107 0x56023c5aea60 WARN                    v4l2 gstv4l2object.c:2947:gst_v4l2_object_probe_caps_for_format:<nvv4l2h265enc0:sink> Could not probe maximum capture size for pixelformat NM12
0:00:00.045609341 115107 0x56023c5aea60 WARN                    v4l2 gstv4l2object.c:2394:gst_v4l2_object_add_interlace_mode:0x56023c59e830 Failed to determine interlace mode
0:00:00.045638398 115107 0x56023c5aea60 WARN                    v4l2 gstv4l2object.c:3056:gst_v4l2_object_get_nearest_size:<nvv4l2h265enc0:src> Unable to try format: Unknown error -1
0:00:00.045644679 115107 0x56023c5aea60 WARN                    v4l2 gstv4l2object.c:2941:gst_v4l2_object_probe_caps_for_format:<nvv4l2h265enc0:src> Could not probe minimum capture size for pixelformat H265
0:00:00.045649304 115107 0x56023c5aea60 WARN                    v4l2 gstv4l2object.c:3056:gst_v4l2_object_get_nearest_size:<nvv4l2h265enc0:src> Unable to try format: Unknown error -1
0:00:00.045654348 115107 0x56023c5aea60 WARN                    v4l2 gstv4l2object.c:2947:gst_v4l2_object_probe_caps_for_format:<nvv4l2h265enc0:src> Could not probe maximum capture size for pixelformat H265
Pipeline is PREROLLING ...
Redistribute latency...
0:00:00.139845986 115107 0x56023c247aa0 WARN          v4l2bufferpool gstv4l2bufferpool.c:1049:gst_v4l2_buffer_pool_start:<nvv4l2h265enc0:pool:src> Uncertain or not enough buffers, enabling copy threshold
0:00:00.142207877 115107 0x56023c5b3580 WARN          v4l2bufferpool gstv4l2bufferpool.c:1499:gst_v4l2_buffer_pool_dqbuf:<nvv4l2h265enc0:pool:src> Driver should never set v4l2_buffer.field to ANY
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Got EOS from element "pipeline0".
Execution ended after 0:00:00.041842276
Setting pipeline to NULL ...
Freeing pipeline ...

Script for testing: test_nvv4l2h265enc.sh (871 Bytes)

Logs:
99_frames.log (3.3 KB)
100_frames.log (3.3 KB)

• Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description)

Hi @tomskih_pa,
====>Is there a configuration parameter for nvv4l2h265enc that prevents it to drop frames?
No, you can refer the link below to find all the paras
https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_plugin_gst-nvvideo4linux2.html#encoder
According to your comment, this is a very low probability problem and it just drops 1 frame. Could you tell us what’s your particular user case?
Also, you can try the cli below and observe the Handling frame information.

gst-launch-1.0 --gst-debug=v4l2videoenc:5 videotestsrc num-buffers=100 !     nvvideoconvert !     nvv4l2h265enc !     filesink location=test.h265

Maybe other plugins drop the frame, like sink plugin. You can try to set the qos=0 paras to filesink and see if this problem happen again. Thanks

Could you tell us what’s your particular user case?

We’re building an application that can dynamically attach sources and sinks to a detector pipeline. Source can be a video or collection of pictures. In case of video it’s no big deal to lost one frame. But in case of pictures it’s important to process all pictures.
Also in our pipeline this problem occurs more often. Once in 20 runs or so.

Also, you can try the cli below and observe the Handling frame information.

Just --gst-debug=v4l2videoenc:5 doesn’t help. According to logs nvv4l2h265enc handled all 100 frames. I turned on tracing and noticed that nvv4l2h265enc got all 100 frames on sink pad but pushed only 99 frames to src pad.

GST_TRACERS=stats \
gst-launch-1.0 --gst-debug=2,v4l2videoenc:5,GST_TRACER:7 \
    videotestsrc num-buffers=100 ! \
    nvvideoconvert ! \
    nvv4l2h265enc ! \
    filesink location=test.h265

Logs on case when nvv4l2h265enc encoded all frames:
tracing_good.log (285.1 KB)

Log snippet
0:00:00.308983467 24900 0x55fe86710580 TRACE             GST_TRACER :0:: buffer, thread-id=(guint64)94551665608064, ts=(guint64)308974662, pad-ix=(uint)4, element-ix=(uint)2, peer-pad-ix=(uint)5, peer-element-ix=(uint)3, buffer-size=(uint)6011, have-buffer-pts=(boolean)1, buffer-pts=(guint64)3133333333, have-buffer-dts=(boolean)1, buffer-dts=(guint64)3133333333, have-buffer-duration=(boolean)1, buffer-duration=(guint64)33333333, buffer-flags=(GstBufferFlags)8192;
0:00:00.309221994 24900 0x55fe8639eaa0 TRACE             GST_TRACER :0:: buffer, thread-id=(guint64)94551661996704, ts=(guint64)309213528, pad-ix=(uint)0, element-ix=(uint)0, peer-pad-ix=(uint)1, peer-element-ix=(uint)1, buffer-size=(uint)115200, have-buffer-pts=(boolean)1, buffer-pts=(guint64)3266666666, have-buffer-dts=(boolean)0, buffer-dts=(guint64)18446744073709551615, have-buffer-duration=(boolean)1, buffer-duration=(guint64)33333334, buffer-flags=(GstBufferFlags)0;
0:00:00.309305842 24900 0x55fe8639eaa0 TRACE             GST_TRACER :0:: buffer, thread-id=(guint64)94551661996704, ts=(guint64)309291562, pad-ix=(uint)2, element-ix=(uint)1, peer-pad-ix=(uint)3, peer-element-ix=(uint)2, buffer-size=(uint)64, have-buffer-pts=(boolean)1, buffer-pts=(guint64)3266666666, have-buffer-dts=(boolean)0, buffer-dts=(guint64)18446744073709551615, have-buffer-duration=(boolean)1, buffer-duration=(guint64)33333334, buffer-flags=(GstBufferFlags)0;
0:00:00.309317050 24900 0x55fe8639eaa0 DEBUG           v4l2videoenc gstv4l2videoenc.c:1277:gst_v4l2_video_enc_handle_frame:<nvv4l2h265enc0> Handling frame 98
0:00:00.309322894 24900 0x55fe8639eaa0 DEBUG           v4l2videoenc gstv4l2videoenc.c:1342:gst_v4l2_video_enc_handle_frame: NO META RETRIEVED BY ENCODER

0:00:00.309389740 24900 0x55fe86710580 TRACE             GST_TRACER :0:: buffer, thread-id=(guint64)94551665608064, ts=(guint64)309381084, pad-ix=(uint)4, element-ix=(uint)2, peer-pad-ix=(uint)5, peer-element-ix=(uint)3, buffer-size=(uint)6034, have-buffer-pts=(boolean)1, buffer-pts=(guint64)3166666666, have-buffer-dts=(boolean)1, buffer-dts=(guint64)3166666666, have-buffer-duration=(boolean)1, buffer-duration=(guint64)33333334, buffer-flags=(GstBufferFlags)8192;
0:00:00.309633045 24900 0x55fe8639eaa0 TRACE             GST_TRACER :0:: buffer, thread-id=(guint64)94551661996704, ts=(guint64)309623775, pad-ix=(uint)0, element-ix=(uint)0, peer-pad-ix=(uint)1, peer-element-ix=(uint)1, buffer-size=(uint)115200, have-buffer-pts=(boolean)1, buffer-pts=(guint64)3300000000, have-buffer-dts=(boolean)0, buffer-dts=(guint64)18446744073709551615, have-buffer-duration=(boolean)1, buffer-duration=(guint64)33333333, buffer-flags=(GstBufferFlags)0;
0:00:00.309705059 24900 0x55fe8639eaa0 TRACE             GST_TRACER :0:: buffer, thread-id=(guint64)94551661996704, ts=(guint64)309698046, pad-ix=(uint)2, element-ix=(uint)1, peer-pad-ix=(uint)3, peer-element-ix=(uint)2, buffer-size=(uint)64, have-buffer-pts=(boolean)1, buffer-pts=(guint64)3300000000, have-buffer-dts=(boolean)0, buffer-dts=(guint64)18446744073709551615, have-buffer-duration=(boolean)1, buffer-duration=(guint64)33333333, buffer-flags=(GstBufferFlags)0;
0:00:00.309715673 24900 0x55fe8639eaa0 DEBUG           v4l2videoenc gstv4l2videoenc.c:1277:gst_v4l2_video_enc_handle_frame:<nvv4l2h265enc0> Handling frame 99
0:00:00.309721858 24900 0x55fe8639eaa0 DEBUG           v4l2videoenc gstv4l2videoenc.c:1342:gst_v4l2_video_enc_handle_frame: NO META RETRIEVED BY ENCODER

0:00:00.309803385 24900 0x55fe86710580 TRACE             GST_TRACER :0:: buffer, thread-id=(guint64)94551665608064, ts=(guint64)309794649, pad-ix=(uint)4, element-ix=(uint)2, peer-pad-ix=(uint)5, peer-element-ix=(uint)3, buffer-size=(uint)5989, have-buffer-pts=(boolean)1, buffer-pts=(guint64)3200000000, have-buffer-dts=(boolean)1, buffer-dts=(guint64)3200000000, have-buffer-duration=(boolean)1, buffer-duration=(guint64)33333333, buffer-flags=(GstBufferFlags)8192;
0:00:00.309858613 24900 0x55fe8639eaa0 TRACE             GST_TRACER :0:: event, thread-id=(guint64)94551661996704, ts=(guint64)309852401, pad-ix=(uint)0, element-ix=(uint)0, name=(string)eos;
0:00:00.309874403 24900 0x55fe8639eaa0 TRACE             GST_TRACER :0:: event, thread-id=(guint64)94551661996704, ts=(guint64)309870519, pad-ix=(uint)2, element-ix=(uint)1, name=(string)eos;
0:00:00.309884151 24900 0x55fe8639eaa0 DEBUG           v4l2videoenc gstv4l2videoenc.c:676:gst_v4l2_video_enc_finish:<nvv4l2h265enc0> Finishing encoding
0:00:00.309900779 24900 0x55fe8639eaa0 DEBUG           v4l2videoenc gstv4l2videoenc.c:641:gst_v4l2_encoder_cmd:<nvv4l2h265enc0> sending v4l2 encoder command 1 with flags 1
0:00:00.310223647 24900 0x55fe86710580 TRACE             GST_TRACER :0:: buffer, thread-id=(guint64)94551665608064, ts=(guint64)310214386, pad-ix=(uint)4, element-ix=(uint)2, peer-pad-ix=(uint)5, peer-element-ix=(uint)3, buffer-size=(uint)6004, have-buffer-pts=(boolean)1, buffer-pts=(guint64)3233333333, have-buffer-dts=(boolean)1, buffer-dts=(guint64)3233333333, have-buffer-duration=(boolean)1, buffer-duration=(guint64)33333333, buffer-flags=(GstBufferFlags)8192;
0:00:00.310637954 24900 0x55fe86710580 TRACE             GST_TRACER :0:: buffer, thread-id=(guint64)94551665608064, ts=(guint64)310628902, pad-ix=(uint)4, element-ix=(uint)2, peer-pad-ix=(uint)5, peer-element-ix=(uint)3, buffer-size=(uint)5986, have-buffer-pts=(boolean)1, buffer-pts=(guint64)3266666666, have-buffer-dts=(boolean)1, buffer-dts=(guint64)3266666666, have-buffer-duration=(boolean)1, buffer-duration=(guint64)33333334, buffer-flags=(GstBufferFlags)8192;
0:00:00.311048920 24900 0x55fe86710580 TRACE             GST_TRACER :0:: buffer, thread-id=(guint64)94551665608064, ts=(guint64)311038459, pad-ix=(uint)4, element-ix=(uint)2, peer-pad-ix=(uint)5, peer-element-ix=(uint)3, buffer-size=(uint)5947, have-buffer-pts=(boolean)1, buffer-pts=(guint64)3300000000, have-buffer-dts=(boolean)1, buffer-dts=(guint64)3300000000, have-buffer-duration=(boolean)1, buffer-duration=(guint64)33333333, buffer-flags=(GstBufferFlags)8192;
0:00:00.311075617 24900 0x55fe86710580 DEBUG           v4l2videoenc gstv4l2videoenc.c:1242:gst_v4l2_video_enc_loop:<nvv4l2h265enc0> Leaving output thread
0:00:00.311136760 24900 0x55fe86710580 TRACE             GST_TRACER :0:: message, thread-id=(guint64)94551665608064, ts=(guint64)311115212, element-ix=(uint)2, name=(string)stream-status, structure=(structure)"GstMessageStreamStatus\,\ type\=\(GstStreamStatusType\)GST_STREAM_STATUS_TYPE_LEAVE\,\ owner\=\(GstElement\)\"\\\(nvv4l2h265enc\\\)\\\ nvv4l2h265enc0\"\,\ object\=\(GstTask\)\"\\\(GstTask\\\)\\\ nvv4l2h265enc0:src\"\;";
0:00:00.311155545 24900 0x55fe86710580 TRACE             GST_TRACER :0:: message, thread-id=(guint64)94551665608064, ts=(guint64)311144502, element-ix=(uint)4, name=(string)stream-status, structure=(structure)"GstMessageStreamStatus\,\ type\=\(GstStreamStatusType\)GST_STREAM_STATUS_TYPE_LEAVE\,\ owner\=\(GstElement\)\"\\\(nvv4l2h265enc\\\)\\\ nvv4l2h265enc0\"\,\ object\=\(GstTask\)\"\\\(GstTask\\\)\\\ nvv4l2h265enc0:src\"\;";
0:00:00.311226853 24900 0x55fe8639eaa0 DEBUG           v4l2videoenc gstv4l2videoenc.c:1260:gst_v4l2_video_enc_loop_stopped:<nvv4l2h265enc0> Encoding task destroyed: eos
0:00:00.311244098 24900 0x55fe8639eaa0 DEBUG           v4l2videoenc gstv4l2videoenc.c:711:gst_v4l2_video_enc_finish:<nvv4l2h265enc0> Done draining buffers
0:00:00.311257342 24900 0x55fe8639eaa0 TRACE             GST_TRACER :0:: event, thread-id=(guint64)94551661996704, ts=(guint64)311250126, pad-ix=(uint)4, element-ix=(uint)2, name=(string)eos;

nvvideoconvert pushed buffer with buffer-pts=(guint64)3300000000 to src pad, nvv4l2h265enc handled it (Handling frame 99) and pushed it to src pad.

Logs on a case when nvv4l2h265enc lost the last frame:
tracing_bad.log (284.7 KB)

Log snippet
0:00:00.283005880 24916 0x55a660b1caa0 TRACE             GST_TRACER :0:: buffer, thread-id=(guint64)94173075196576, ts=(guint64)282995067, pad-ix=(uint)0, element-ix=(uint)0, peer-pad-ix=(uint)1, peer-element-ix=(uint)1, buffer-size=(uint)115200, have-buffer-pts=(boolean)1, buffer-pts=(guint64)3266666666, have-buffer-dts=(boolean)0, buffer-dts=(guint64)18446744073709551615, have-buffer-duration=(boolean)1, buffer-duration=(guint64)33333334, buffer-flags=(GstBufferFlags)0;
0:00:00.283092095 24916 0x55a660b1caa0 TRACE             GST_TRACER :0:: buffer, thread-id=(guint64)94173075196576, ts=(guint64)283082743, pad-ix=(uint)2, element-ix=(uint)1, peer-pad-ix=(uint)3, peer-element-ix=(uint)2, buffer-size=(uint)64, have-buffer-pts=(boolean)1, buffer-pts=(guint64)3266666666, have-buffer-dts=(boolean)0, buffer-dts=(guint64)18446744073709551615, have-buffer-duration=(boolean)1, buffer-duration=(guint64)33333334, buffer-flags=(GstBufferFlags)0;
0:00:00.283107767 24916 0x55a660b1caa0 DEBUG           v4l2videoenc gstv4l2videoenc.c:1277:gst_v4l2_video_enc_handle_frame:<nvv4l2h265enc0> Handling frame 98
0:00:00.283115046 24916 0x55a660b1caa0 DEBUG           v4l2videoenc gstv4l2videoenc.c:1342:gst_v4l2_video_enc_handle_frame: NO META RETRIEVED BY ENCODER

0:00:00.283326772 24916 0x55a660b1caa0 TRACE             GST_TRACER :0:: buffer, thread-id=(guint64)94173075196576, ts=(guint64)283317828, pad-ix=(uint)0, element-ix=(uint)0, peer-pad-ix=(uint)1, peer-element-ix=(uint)1, buffer-size=(uint)115200, have-buffer-pts=(boolean)1, buffer-pts=(guint64)3300000000, have-buffer-dts=(boolean)0, buffer-dts=(guint64)18446744073709551615, have-buffer-duration=(boolean)1, buffer-duration=(guint64)33333333, buffer-flags=(GstBufferFlags)0;
0:00:00.283408427 24916 0x55a660b1caa0 TRACE             GST_TRACER :0:: buffer, thread-id=(guint64)94173075196576, ts=(guint64)283400409, pad-ix=(uint)2, element-ix=(uint)1, peer-pad-ix=(uint)3, peer-element-ix=(uint)2, buffer-size=(uint)64, have-buffer-pts=(boolean)1, buffer-pts=(guint64)3300000000, have-buffer-dts=(boolean)0, buffer-dts=(guint64)18446744073709551615, have-buffer-duration=(boolean)1, buffer-duration=(guint64)33333333, buffer-flags=(GstBufferFlags)0;
0:00:00.283421233 24916 0x55a660b1caa0 DEBUG           v4l2videoenc gstv4l2videoenc.c:1277:gst_v4l2_video_enc_handle_frame:<nvv4l2h265enc0> Handling frame 99
0:00:00.283427866 24916 0x55a660b1caa0 DEBUG           v4l2videoenc gstv4l2videoenc.c:1342:gst_v4l2_video_enc_handle_frame: NO META RETRIEVED BY ENCODER

0:00:00.283657128 24916 0x55a660b1caa0 TRACE             GST_TRACER :0:: event, thread-id=(guint64)94173075196576, ts=(guint64)283647908, pad-ix=(uint)0, element-ix=(uint)0, name=(string)eos;
0:00:00.283668154 24916 0x55a660e8e580 TRACE             GST_TRACER :0:: buffer, thread-id=(guint64)94173078807936, ts=(guint64)283652875, pad-ix=(uint)4, element-ix=(uint)2, peer-pad-ix=(uint)5, peer-element-ix=(uint)3, buffer-size=(uint)5989, have-buffer-pts=(boolean)1, buffer-pts=(guint64)3200000000, have-buffer-dts=(boolean)1, buffer-dts=(guint64)3200000000, have-buffer-duration=(boolean)1, buffer-duration=(guint64)33333333, buffer-flags=(GstBufferFlags)8192;
0:00:00.283674132 24916 0x55a660b1caa0 TRACE             GST_TRACER :0:: event, thread-id=(guint64)94173075196576, ts=(guint64)283671459, pad-ix=(uint)2, element-ix=(uint)1, name=(string)eos;
0:00:00.283694246 24916 0x55a660b1caa0 DEBUG           v4l2videoenc gstv4l2videoenc.c:676:gst_v4l2_video_enc_finish:<nvv4l2h265enc0> Finishing encoding
0:00:00.283711313 24916 0x55a660b1caa0 DEBUG           v4l2videoenc gstv4l2videoenc.c:641:gst_v4l2_encoder_cmd:<nvv4l2h265enc0> sending v4l2 encoder command 1 with flags 1
0:00:00.284083073 24916 0x55a660e8e580 TRACE             GST_TRACER :0:: buffer, thread-id=(guint64)94173078807936, ts=(guint64)284069672, pad-ix=(uint)4, element-ix=(uint)2, peer-pad-ix=(uint)5, peer-element-ix=(uint)3, buffer-size=(uint)6004, have-buffer-pts=(boolean)1, buffer-pts=(guint64)3233333333, have-buffer-dts=(boolean)1, buffer-dts=(guint64)3233333333, have-buffer-duration=(boolean)1, buffer-duration=(guint64)33333333, buffer-flags=(GstBufferFlags)8192;
0:00:00.288788605 24916 0x55a660e8e580 TRACE             GST_TRACER :0:: buffer, thread-id=(guint64)94173078807936, ts=(guint64)288761922, pad-ix=(uint)4, element-ix=(uint)2, peer-pad-ix=(uint)5, peer-element-ix=(uint)3, buffer-size=(uint)5986, have-buffer-pts=(boolean)1, buffer-pts=(guint64)3266666666, have-buffer-dts=(boolean)1, buffer-dts=(guint64)3266666666, have-buffer-duration=(boolean)1, buffer-duration=(guint64)33333334, buffer-flags=(GstBufferFlags)8192;
0:00:00.288945960 24916 0x55a660e8e580 DEBUG           v4l2videoenc gstv4l2videoenc.c:1242:gst_v4l2_video_enc_loop:<nvv4l2h265enc0> Leaving output thread
0:00:00.289009024 24916 0x55a660e8e580 TRACE             GST_TRACER :0:: message, thread-id=(guint64)94173078807936, ts=(guint64)288986315, element-ix=(uint)2, name=(string)stream-status, structure=(structure)"GstMessageStreamStatus\,\ type\=\(GstStreamStatusType\)GST_STREAM_STATUS_TYPE_LEAVE\,\ owner\=\(GstElement\)\"\\\(nvv4l2h265enc\\\)\\\ nvv4l2h265enc0\"\,\ object\=\(GstTask\)\"\\\(GstTask\\\)\\\ nvv4l2h265enc0:src\"\;";
0:00:00.289028218 24916 0x55a660e8e580 TRACE             GST_TRACER :0:: message, thread-id=(guint64)94173078807936, ts=(guint64)289017540, element-ix=(uint)4, name=(string)stream-status, structure=(structure)"GstMessageStreamStatus\,\ type\=\(GstStreamStatusType\)GST_STREAM_STATUS_TYPE_LEAVE\,\ owner\=\(GstElement\)\"\\\(nvv4l2h265enc\\\)\\\ nvv4l2h265enc0\"\,\ object\=\(GstTask\)\"\\\(GstTask\\\)\\\ nvv4l2h265enc0:src\"\;";
0:00:00.289356846 24916 0x55a660b1caa0 DEBUG           v4l2videoenc gstv4l2videoenc.c:1260:gst_v4l2_video_enc_loop_stopped:<nvv4l2h265enc0> Encoding task destroyed: eos
0:00:00.289378177 24916 0x55a660b1caa0 DEBUG           v4l2videoenc gstv4l2videoenc.c:711:gst_v4l2_video_enc_finish:<nvv4l2h265enc0> Done draining buffers
0:00:00.289391144 24916 0x55a660b1caa0 TRACE             GST_TRACER :0:: event, thread-id=(guint64)94173075196576, ts=(guint64)289384558, pad-ix=(uint)4, element-ix=(uint)2, name=(string)eos;

nvv4l2h265enc handled the last frame (Handling frame 99) but didn’t push it to src pad.

qos=0 on filesink doesn’t affect this problem.

Hi @tomskih_pa, according the log, the encoder already handle 100 frames. It may be that the gstreamer sink plug-in is more likely to lose frames instead of nvv4l2h265enc handled the last frame (Handling frame 99) but didn’t push it to src pad. Cause the gstreamer basesink plugin have some logic to drop frame.
So you can set sync=false and QoS=0 parameters at the same time.

I already tried parameters sync=0 qos=0 on filesink. nvv4l2h265enc still drop frames.

I’ve run some tests. Only nvv4l2h264enc and nvv4l2h265enc drop frames occasionally. x264enc and x265enc always render all frames.

Logs:
nvv4l2h264enc_frame_dropped.log (491.4 KB)
nvv4l2h264enc_ok.log (493.6 KB)
nvv4l2h265enc_frame_dropped.log (490.4 KB)
nvv4l2h265enc_ok.log (492.9 KB)
x264enc_ok.log (461.2 KB)
x265enc_ok.log (447.7 KB)

According to logs basesink doesn’t drop buffers. It doesn’t even receive those dropped buffers.

0:00:00.269020819 404769 0x55d75f4b3b00 DEBUG               basesink gstbasesink.c:5300:gst_base_sink_change_state:<filesink0> rendered: 99, dropped: 0

Hi @tomskih_pa , I run the pipeline in my env(deepstream 6.1, T4 server) for 500~600 times. It didn’t drop frame. So could you help open the log of gstvideoencoder.c? This is where the encoder logic to drop frames. Just add the paras --gst-debug=videoencoder:7 in your pipeline.

Hi @yuweiw , sorry for the delay. I’ve added videoencoder:7 to gst-debug. Here are the logs:
videoencoder_log_ok.log (697.4 KB)
videoencoder_log_lost_frame.log (694.6 KB)

The last one missing gst_video_encoder_finish_frame:<nvv4l2h265enc0> finish frame fpn 99 message.

Ok, we’ll debug it in our source code. If there is any conclusion, I will inform you as soon as possible.
Also If you have time, you can try it with our latest Deepstream version 6.1.1. Thanks

Hi @tomskih_pa , What is the probability of your problem in your env? In our env, it’s less than 0.1% which is too hard to repro.

Hi @yuweiw

I found a way to reproduce a bug almost every time.

  1. Run gstreamer on only one CPU core.
  2. Add a second nvv4l2h265enc and queues between elements.
docker run \
    --rm \
    --name test \
    --cpuset-cpus 0 \
    --gpus all \
    -e GST_DEBUG=2 \
    -v "$(pwd)/result:/result" \
    --entrypoint gst-launch-1.0 \
    nvcr.io/nvidia/deepstream:6.1.1-base \
    videotestsrc num-buffers=100 ! \
    'video/x-raw,width=720,height=480' ! \
    queue ! \
    nvvideoconvert ! \
    queue ! \
    nvv4l2h265enc ! \
    queue ! \
    h265parse ! \
    queue ! \
    nvv4l2decoder ! \
    queue ! \
    nvv4l2h265enc ! \
    queue ! \
    filesink qos=0 sync=0 location=/result/test.h265

Thanks for that, we’ll analyze it as soon as possible.

We have fixed this issue with the latest version. Please upgrade to the latest version and try. Thanks