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.