I have no experience with libcamerasrc, though the source elements of gstreamer would derive from GstBaseSrc, that has a member num-buffers (the doc link lacks a description). The source element would terminate after this number of buffers (images in your case), so you would just use: