Environment: GeForce RTX 2060 with Driver Version: 430.26 and CUDA Version: 10.2
I am looking to save the individual (decoded) NV12 frames into a separate data store and So I tried to extend the code into the deepstream_test3_app.c as explained below
** Registering callback for every frame received over PGIE sink (same as streammux src pad) **
streammux_src_pad = gst_element_get_static_pad (pgie, "sink");
if (!streammux_src_pad)
g_print ("Unable to get streammux sink pad\n");
else
gst_pad_add_probe (streammux_src_pad, GST_PAD_PROBE_TYPE_BUFFER,
streammux_src_pad_buffer_probe, NULL, NULL);
** Inside streammux_src_pad_buffer_probe( ) called for every frame received **
static GstPadProbeReturn
streammux_src_pad_buffer_probe (GstPad * pad, GstPadProbeInfo * info,
gpointer u_data)
{
...
GstMapInfo in_map_info;
NvBufSurface *surface = NULL;
GstBuffer *inbuf = gst_pad_probe_info_get_buffer(info);
memset (&in_map_info, 0, sizeof (in_map_info));
if (!gst_buffer_map (inbuf, &in_map_info, GST_MAP_READ)) {
g_print ("Error: Failed to map gst buffer\n");
goto error;
}
surface = (NvBufSurface *) in_map_info.data;
// Writing surface buffer into file
fwrite(surface->surfaceList[0].dataPtr, surface->surfaceList[0].dataSize, 1, fp1);
...
}
Then I try to input the dumped frames/files into a mjpg video using ffmpeg
ffmpeg -s:v 1920x1080 -r 20 -pix_fmt nv12 -i img_%d.raw out.mjpg
Result is, when I play out.mjpg with VLC, just a few frames are played and stopped, but its not a full video as the source video. Though I am through partially, I am assuming I may have missed to run a loop/indexing somewhere required - which is not very clear from the examples and the documentation referred.
Ref : /root/deepstream_sdk_v4.0_x86_64/sources/gst-plugins/gst-dsexample/gstdsexample.cpp
Ref : NVIDIA DeepStream SDK API Reference: NvBufSurface Struct Reference
Additional reference : /deepstream_sdk_v4.0_x86_64/sources/gst-plugins/gst-nvinfer/gstnvinfer_allocator.cpp
/* Calculate pointers to individual frame memories in the batch memory and
* insert in the vector. */
tmem->frame_memory_ptrs[i] = (char *) tmem->surf->surfaceList[i].dataPtr;
So can you please let me know what am I missing?
Requirement being - I am NOT supposed to do any transform of the NV12 buffer (reaching as input to PGIE) but just faithfully store/pass those decoded frames for another application usage.