I have a DeepStream pipeline taking in camera data and saving it at the output into an mp4 file. I want to add the NTP timestamp of the first frame from each saved video to the filename of the video, but I am having trouble getting this to work. Here’s what I am doing now:
Inside of create_encode_file_bin
, I have g_signal_connect(bin->sink, "format-location-full", G_CALLBACK(callback_ringbuf_format_location), config);
, where callback_ringbuf_format_location
attempts to get NTP timestamp of next frame in following way:
static gchar *callback_ringbuf_format_location(GstElement *splitmux,
guint fragment_id,
GstSample *first_sample,
NvDsSinkEncoderConfig *config) {
...
GstBuffer *buf = gst_sample_get_buffer(first_sample);
NvDsBatchMeta *batch_meta = gst_buffer_get_nvds_batch_meta(buf);
if (batch_meta == NULL || batch_meta->num_frames_in_batch == 0) {
NVGSTDS_ERR_MSG_V("Ringbuffer Sink: failed to get batch metadata "
"associated with incoming buffer");
}
NvDsMetaList *l_frame = batch_meta->frame_meta_list;
NvDsFrameMeta *frame_meta = l_frame->data;
if (frame_meta == NULL) {
NVGSTDS_ERR_MSG_V("Ringbuffer Sink: failed to get frame metadata "
"associated with incoming buffer");
}
guint64 ntp_timestamp = frame_meta->ntp_timestamp;
For some reason, batch_meta
is always NULL. My impression is that the parameter first_sample
contains a reference to the first GstBuffer
that goes in the next file, but then it seems like I should also be able to access the batch meta for that buffer.