Mp4 file source instead of nvarguscamerasrc

Hello,

My current gstreamer pipeline which uses deepstream SDK is the following:

gst-launch-1.0  nvarguscamerasrc bufapi-version=1 ! 'video/x-raw(memory:NVMM),width=3264,height=2464,framerate=21/1' ! mx.sink_0 nvstreammux width=3264 height=2464  batch-size=1 name=mx ! mypluygin ! nvv4l2h264enc ! h264parse ! qtmux ! filesink location=test.mp4 -e

Now I want to exchange nvarguscamerasrc bufapi-version=1 with a mp4 filesource, but I couldn’t find nvidia deepstream plugin for this. What plugin do I have to use?

Hi @elhe,

You don’t need a deepstream plugin to do this, you can try read from a mp4 file with the following pipeline:

filesrc location=$PATH_TO_MP4 ! decodebin ! nvvideoconvert ! 'video/x-raw(memory:NVMM)' ! mx.sink_0 nvstreammux width=3264 height=2464 batch-size=1 name=mx ! mypluygin ! nvv4l2h264enc ! h264parse ! qtmux ! filesink location=test.mp4 -e

Just make sure to check the dimensions of the video file so you can adjust them in the nvstreammux element.

Best Regards,
Jimena Salas

1 Like

Hi @JimenaSalas , thanks for your answer.

Unfortunately when I use the pipeline mentioned by you, I get a SIGSEGV at what I guess is decoding.

Setting pipeline to PAUSED ...                                                                                                                                                                                                                                                       Opening in BLOCKING MODE                                             
Opening in BLOCKING MODE                                                                                                                  
0:00:01.637812500 12443   0x55a1ee4f80 WARN                    v4l2 gstv4l2object.c:2375:gst_v4l2_object_add_interlace_mode:0x55a1fa4400 Failed to determine interlace mode
0:00:01.637893964 12443   0x55a1ee4f80 WARN                    v4l2 gstv4l2object.c:2375:gst_v4l2_object_add_interlace_mode:0x55a1fa4400 Failed to determine interlace mode
0:00:01.637941519 12443   0x55a1ee4f80 WARN                    v4l2 gstv4l2object.c:2375:gst_v4l2_object_add_interlace_mode:0x55a1fa4400 Failed to determine interlace mode
0:00:01.638036681 12443   0x55a1ee4f80 WARN                    v4l2 gstv4l2object.c:4434:gst_v4l2_object_probe_caps:<nvv4l2h264enc0:src> Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Unknown error -1
0:00:01.729797892 12443   0x55a1ee4f80 WARN                 basesrc gstbasesrc.c:3583:gst_base_src_start_complete:<filesrc0> pad not activated yet                         
Pipeline is PREROLLING ...                                                                                                                                                                                                                                                           
0:00:01.743695368 12443   0x7f7c061230 WARN                 qtdemux qtdemux.c:3031:qtdemux_parse_trex:<qtdemux0> failed to find fragment defaults for stream 1                                                   
Opening in BLOCKING MODE                                                                                                                                                                                                                                                             
Opening in BLOCKING MODE                                                                                                                  
0:00:01.788118956 12443   0x7f7c061770 WARN                    v4l2 gstv4l2object.c:4434:gst_v4l2_object_probe_caps:<nvv4l2decoder0:src> Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Unknown error -1
0:00:01.788178230 12443   0x7f7c061770 WARN                    v4l2 gstv4l2object.c:2375:gst_v4l2_object_add_interlace_mode:0x7f680209b0 Failed to determine interlace mode
0:00:01.788231515 12443   0x7f7c061770 WARN                    v4l2 gstv4l2object.c:2375:gst_v4l2_object_add_interlace_mode:0x7f680209b0 Failed to determine interlace mode
NvMMLiteOpen : Block : BlockType = 261                                                                                                                                                                                                                                               
NVMEDIA: Reading vendor.tegra.display-size : status: 6                                                                                                                                                                                                                               
NvMMLiteBlockCreate : Block : BlockType = 261                                                                                                                                                                                                                                        
0:00:01.892503554 12443   0x7f7c061770 WARN                    v4l2 gstv4l2object.c:4434:gst_v4l2_object_probe_caps:<nvv4l2decoder0:src> Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Unknown error -1
0:00:01.892735807 12443   0x7f7c061770 WARN                    v4l2 gstv4l2object.c:2375:gst_v4l2_object_add_interlace_mode:0x7f680209b0 Failed to determine interlace mode
0:00:01.892975562 12443   0x7f7c061770 WARN                    v4l2 gstv4l2object.c:2375:gst_v4l2_object_add_interlace_mode:0x7f680209b0 Failed to determine interlace mode
Redistribute latency...                                                                                                                                                                                                                                                              
NvMMLiteOpen : Block : BlockType = 4                                                                                                                                                                                                                                                 
===== NVMEDIA: NVENC =====                                                                                                                                                                                                                                                           
NvMMLiteBlockCreate : Block : BlockType = 4                                                                                               
0:00:01.912166700 12443   0x7f7c061770 WARN          v4l2bufferpool gstv4l2bufferpool.c:1065:gst_v4l2_buffer_pool_start:<nvv4l2h264enc0:pool:src> Uncertain or not enough buffers, enabling copy threshold
0:00:01.914677689 12443   0x7f7c061770 WARN            v4l2videodec gstv4l2videodec.c:1673:gst_v4l2_video_dec_decide_allocation:<nvv4l2decoder0> Duration invalid, not setting latency
0:00:01.918257755 12443   0x7f7c061770 WARN          v4l2bufferpool gstv4l2bufferpool.c:1065:gst_v4l2_buffer_pool_start:<nvv4l2decoder0:pool:src> Uncertain or not enough buffers, enabling copy threshold
0:00:02.012765750 12443   0x7f680144f0 WARN          v4l2bufferpool gstv4l2bufferpool.c:1512:gst_v4l2_buffer_pool_dqbuf:<nvv4l2decoder0:pool:src> Driver should never set v4l2_buffer.field to ANY        
Caught SIGSEGV     

I verified, that the resolution of the mp4 video is 3264x2464 (see information from vlc).
Screenshot from 2021-09-22 12-43-43

This is the output of the verbose mode where you can see clearly that all caps are matching:

===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4 
/GstPipeline:pipeline0/nvv4l2h264enc:nvv4l2h264enc0.GstPad:sink: caps = video/x-raw(memory:NVMM), width=(int)3264, height=(int)2464, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, framerate=(fraction)25/1, format=(string)NV12, batch-size=(int)1, num-surfaces-per-frame=(int)1
/GstPipeline:pipeline0/GstMyPlugin:myplugin0.GstPad:sink: caps = video/x-raw(memory:NVMM), width=(int)3264, height=(int)2464, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, framerate=(fraction)25/1, format=(string)NV12, batch-size=(int)1, num-surfaces-per-frame=(int)1
/GstPipeline:pipeline0/GstNvStreamMux:mx.GstNvStreamPad:sink_0: caps = video/x-raw(memory:NVMM), width=(int)3264, height=(int)2464, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)25/1, format=(string)NV12
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:sink: caps = video/x-raw(memory:NVMM), width=(int)3264, height=(int)2464, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)25/1, format=(string)NV12
/GstPipeline:pipeline0/Gstnvvideoconvert:nvvideoconvert0.GstPad:sink: caps = video/x-raw(memory:NVMM), format=(string)NV12, width=(int)3264, height=(int)2464, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, chroma-site=(string)mpeg2, colorimetry=(string)bt2020, framerate=(fraction)25/1
/GstPipeline:pipeline0/GstDecodeBin:decodebin0.GstDecodePad:src_0.GstProxyPad:proxypad2: caps = video/x-raw(memory:NVMM), format=(string)NV12, width=(int)3264, height=(int)2464, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, chroma-site=(string)mpeg2, colorimetry=(string)bt2020, framerate=(fraction)25/1
Caught SIGSEGV
#0  0x0000007f92cafe28 in __GI___poll (fds=0x558b9efa50, nfds=547924726664, timeout=<optimized out>) at ../sysdeps/unix/sysv/linux/poll.c:41
#1  0x0000007f92dbcf58 in  () at /usr/lib/aarch64-linux-gnu/libglib-2.0.so.0
#2  0x000000558b29eba0 in  ()

Do you have any idea what causes this behavior?

Hi @JimenaSalas ,
After more research into the SIGSEGV I am getting, I found out that when reading from file, the pitch of a frame I generate in myplugin changes to a different value, although the resolution is the same. I opened another topic for this, because it is not the same problem.
See this topic