Problems with deepstream reading local images

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU)
• DeepStream Version
• JetPack Version (valid for Jetson only)
• TensorRT Version
• Issue Type( questions, new requirements, bugs)
Use DeepStream to read a local JPEG image and display only the first image locally。
the code is ::

int main ()
guint bus_watch_id;

GstElement *pipeline,*bin,*parser,*decoder, *streammux, *nvvidconv, *transform,*sink,*filter2,*convert3,*tiler,*nvdslogger, *seg,*nvsegvisual,*tee, *nvvidconv1,*sink1 ,*nvinfer,*nvosd;
GMainLoop *loop = NULL;
GstBus *bus;
CustomData data1;

gst_init (NULL, NULL);
loop = g_main_loop_new (NULL, FALSE);
pipeline = gst_pipeline_new (“dstensor-pipeline”);

GstElement *queue1, *queue2, *queue3;
queue1 = gst_element_factory_make (“queue”, “queue1”);
queue2 = gst_element_factory_make (“queue”, “queue2”);
queue3 = gst_element_factory_make (“queue”, “queue3”);

bin=gst_bin_new (“new-bin”);
data1.source = gst_element_factory_make (“multifilesrc”, “file-source0”);
parser = gst_element_factory_make (“jpegparse”, “jpeg-parser0”);
decoder = gst_element_factory_make (“nvv4l2decoder”, “nvv4l2-decoder0”);

streammux = gst_element_factory_make (“nvstreammux”, “stream-muxer”);

nvdslogger = gst_element_factory_make (“nvdslogger”, “nvdslogger”);
transform = gst_element_factory_make(“nvegltransform”, “transform”);

nvvidconv = gst_element_factory_make (“nvvideoconvert”, “nvvideo-converter”);
sink = gst_element_factory_make (“nveglglessink”, “nvvideo-renderer”);

gst_bin_add_many (GST_BIN (bin),data1.source, parser, decoder, NULL);

GstPad *source_pad = gst_element_get_static_pad(decoder, “src”);

seg = gst_element_factory_make (“nvinfer”, “primary-nvinference-engine”);
g_object_set (G_OBJECT (seg),
“config-file-path”, “hdmapnet.txt”, NULL);

nvsegvisual = gst_element_factory_make (“nvsegvisual”, “nvsegvisual”);
g_object_set (G_OBJECT (nvsegvisual), “batch-size”, 1, NULL);
g_object_set (G_OBJECT (nvsegvisual), “width”, 800, NULL);
g_object_set (G_OBJECT (nvsegvisual), “height”, 400, NULL);

nvosd = gst_element_factory_make (“nvdsosd”, “nv-onscreendisplay”);

if (!gst_element_link_many (data1.source, parser, decoder, NULL))
g_printerr (“Elements could not be linked: 0. Exiting.\n”);
return -1;

gst_bin_add_many (GST_BIN (pipeline),bin,streammux,queue1,nvdslogger,queue2,queue3,
nvvidconv, transform, sink,NULL);

if (!pipeline||!data1.source || !parser || !decoder||!streammux || !nvvidconv ||!transform ) {
g_printerr (“One element could not be created. Exiting.\n”);
return -1;

g_object_set(G_OBJECT(data1.source), “location”,“/home/titan/detetct_image/image_%d.jpeg”, NULL);

g_object_set(G_OBJECT( streammux),“width”,1024,“height”,1024, “batch-size”, 1, “batched-push-timeout”, MUXER_BATCH_TIMEOUT_USEC,NULL);
g_object_set (G_OBJECT(sink), “sync”, FALSE, NULL);
// g_object_set (G_OBJECT (sink), “qos”, 0, NULL);

GstPad *sinkpad,*srcpad;
gchar pad_name_src[16] = “src”;
gchar pad_name_sink[16] = “sink_0”;

srcpad = gst_element_get_static_pad (bin, pad_name_src);
if (!srcpad) {
g_printerr (“Decoder request src pad failed. Exiting.\n”);
return -1;

sinkpad = gst_element_get_request_pad (streammux, pad_name_sink);
if (!sinkpad) {
g_printerr (“Streammux request sink pad failed. Exiting.\n”);
return -1;

if (gst_pad_link (srcpad, sinkpad) != GST_PAD_LINK_OK) {
g_printerr (“Failed to link decoder to stream muxer1. Exiting.\n”);
return -1;

if (!gst_element_link_many (streammux,queue1,nvdslogger,queue2,queue3,nvvidconv,transform, sink,NULL)) {
g_printerr (“Elements could not be linked: 2. Exiting.\n”);
return -1;

//进行 修改图像
//GstPad *tiler_src_pad =gst_element_get_static_pad(data1.source,“src”);
//gst_pad_add_probe (tiler_src_pad, GST_PAD_PROBE_TYPE_BUFFER,seg_src_pad_buffer_probe, &data1, NULL); //模型推理的输出

GstPad *tiler_src_pad_s =gst_element_get_static_pad (streammux,“src”);
gst_pad_add_probe (tiler_src_pad_s, GST_PAD_PROBE_TYPE_BUFFER,tile_sink_pad_buffer_probe, NULL, NULL);

//GstPad *tiler_src_pad_s =gst_element_get_static_pad ( nvosd,“sink”);
//gst_pad_add_probe (tiler_src_pad_s, GST_PAD_PROBE_TYPE_BUFFER,nvinfer_src_pad_buffer_probe1, NULL, NULL); //修改了图像大小

//GstPad *tiler_src_pad_c =gst_element_get_static_pad (nvdslogger,“sink”);
//gst_pad_add_probe (tiler_src_pad_c, GST_PAD_PROBE_TYPE_BUFFER,nvinfer_src_pad_buffer_probe1, NULL, NULL);

GST_DEBUG_GRAPH_SHOW_ALL, “pipeline-playing”);

gst_element_set_state (pipeline, GST_STATE_PLAYING);
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
bus_watch_id = gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);

/* Iterate */
g_print (“Running…\n”);
g_main_loop_run (loop);

/* Out of the main loop, clean up nicely */
g_print (“Returned, stopping playback\n”);
gst_element_set_state (pipeline, GST_STATE_NULL);
g_print (“Deleting pipeline\n”);
gst_object_unref (GST_OBJECT (pipeline));
g_source_remove (bus_watch_id);
g_main_loop_unref (loop);

return 0;

please refer to sample deepstream-image-decode-test in DS6.1 or deepstream-can-orientation-app in DS6.2, they all use multifilesrc to read jpeg files.

I refer to his , only I read the folder. The image is named image_0.jpeg~image_734.jpeg

can you share the error logs and configurations?
reading jpeg files is in Gstreamer 's code, please refer to gst-plugins-good/gstmultifilesrc.c at master · Kurento/gst-plugins-good · GitHub

The code runs smoothly, but only shows the first image。
v4l2_test2.cpp (4.9 KB) (57.1 MB)

The problem is seen through DEBUG ::v4l2 gstv4l2object.c:4481:gst_v4l2_object_probe_caps:nvv4l2-decoder0:src Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Unknown error -1。
How to solve?

please ignore this debug log.
you can open Gstreamer debug log by doing “export GST_DEBUG=6”, then check if multifilesrc is reading jpg file one by one, here is the keyword “reading from file”, please refer to gst-plugins-good/gstmultifilesrc.c at master · GStreamer/gst-plugins-good · GitHub

I used nvjpegdec instead of nvv4l2decoder, which can be displayed. But when the split network is inserted, an error is displayed. ERROR jpegdec gstjpegdec.c:1147:gst_jpeg_dec_negotiate: Empty caps

what do you mean about “split network is inserted”? please refer to the following pipelines, they work fine.
gst-launch-1.0 filesrc location=test_sample_0043.jpg ! nvjpegdec ! nvvideoconvert ! ‘video/x-raw,format=NV12’ ! jpegenc ! filesink location=7.jpeg
gst-launch-1.0 multifilesrc location=/home/movies/pic/dump265jpg/“h265frame%d.jpg” index=0 caps=“image/jpeg,framerate=(fraction)20/1” ! jpegdec ! videoconvert ! ‘video/x-raw,format=I420’ ! nvvideoconvert nvbuf-memory-type=3 ! ‘video/x-raw(memory:NVMM),format=NV12’ ! mux.sink_0 nvstreammux name=mux batch-size=1 width=1920 height=1080 nvbuf-memory-type=3 ! nvinfer config-file-path=./pgie_peopleSegNetv2_tao_config.txt ! nvvideoconvert ! ‘video/x-raw(memory:NVMM),format=RGBA’ ! nvdsosd ! fakesink.

This is my flowchart for gstreamer

Running the following commands should work:

gst-launch-1.0 multifilesrc location=/home/titan/detetct_image/“image_%d.jpeg” index=0 ! jpegdec ! videoconvert ! ‘video/x-raw,format=I420’ ! nvvideoconvert ! ‘video/x-raw(memory:NVMM),format=NV12’ ! mux.sink_0 nvstreammux name=mux batch-size=1 width=1024 height=1024 ! nvdslogger ! nvinfer config-file-path=/home/titan/deepstream_cui/build/hdmapnet.txt ! nvsegvisual ! nvvideoconvert ! nvegltransform ! nveglglessink

There is no update from you for a period, assuming this is not an issue anymore. Hence we are closing this topic. If need further support, please open a new one. Thanks

Sorry for the late reply, Is this still an DeepStream issue to support?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.