Lost frame detected

Hello,

Here’s my problem: I want to record two-minute videos with this pipeline, in 1920*1080 at 30 frames per second :

v4l2src device=/dev/video0 io-mode=2 ! videoconvert  ! video/x-raw, format=UYVY,framerate=30/1,width=1920,height=1080 ! queue max-size-buffers=32 max-size-bytes=0 max-size-time=0 ! v4l2h264enc extra-controls="encode,h264_profile=4,video_bitrate=25000000" ! video/x-h264,level=(string)5 ! h264parse config-interval=1 ! tee name=mytee  ! queue ! appsink  name=mysink mytee. ! queue  ! splitmuxsink location=output.mp4 name=fsink muxer=matroskamux max-size-time=120000000000

When I start recording, the following warning message appears:
Over a two-minute video, this error appears around 1,600 times, or more than a third of the frames that are lost.

0:00:00.872880243  3924  0x1763cf8 WARN          v4l2bufferpool gstv4l2bufferpool.c:814:gst_v4l2_buffer_pool_start:<v4l2h264enc0:pool0:src> Uncertain or not enough buffers, enabling copy threshold
0:00:00.936369818  3924  0x1763d30 WARN                 v4l2src gstv4l2src.c:1001:gst_v4l2src_create:<v4l2src0> lost frames detected: count = 1 - ts: 0:00:00.740476016

Here is the C++ code used to launch this pipeline:

    GstElement* pipeline = gst_parse_launch(pipeline_str.c_str(), &err);
    /* we add a message handler */
    bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
    bus_watch_id = gst_bus_add_watch (bus, bus_call, loop);
    gst_object_unref (bus);
    GstElement* source = gst_bin_get_by_name(GST_BIN(pipeline), "bin");
    GValue set_auto = G_VALUE_INIT;
    g_value_init(&set_auto, G_TYPE_BOOLEAN);
    g_value_set_boolean(&set_auto, FALSE);
    g_value_unset( &set_auto );
    /*Connection des signaux pour l'écriture du CSV*/
    GstElement* fsink = gst_bin_get_by_name(GST_BIN(pipeline), "fsink");
    /* récupérer le signal de l'application (appsink dans le pipeline*/
    GstElement* sink = gst_bin_get_by_name(GST_BIN(pipeline), "mysink");
    /* demander à appsink de nous avertir lorsqu'il reçoit une image*/
    g_object_set(G_OBJECT(sink), "emit-signals", TRUE, NULL);
    UserData data = { &file_list_images, absolutTimestamp };
    /* indiquer à appsink la fonction à appeler lorsqu'il nous notifie */
    g_signal_connect(sink, "new-sample", G_CALLBACK(callback), &data);
    gst_object_unref(sink);
    /*définit le chemin d'enregistrement des vidéo*/
    g_object_set(G_OBJECT(fsink), "location", (basename+"_%05d.mp4").c_str(), NULL);
    gst_element_set_state(pipeline, GST_STATE_PLAYING);

Do you have any solutions to correct this problem?

ps :This code is run on a raspberry pi 4