Hi,
Please refer to this sample:
GStreamer freeze when using qtmux and NVIDIA-accelerated h264/h265 encoding - #7 by DaneLLL
You can send EoS by calling:
gst_element_send_event (src, gst_event_new_eos ());
Please try this method and see if it works.