How can the `nvv4l2decoder` element support dynamic resolution modification?

pipeline:

appsrc ! h264parse ! nvv4l2decoder ! appsink

Hello, my video data comes from the memory. When the data reaches the nvv4l2decoder, the pipeline is stuck. I try to use the output-selector element to switch the nvv4l2decoder element and it is still stuck.

Please provide complete information as applicable to your setup.
• Hardware Platform (Jetson / GPU)
• DeepStream Version
• JetPack Version (valid for Jetson only)
• TensorRT Version
• NVIDIA GPU Driver Version (valid for GPU only)
• Issue Type( questions, new requirements, bugs)
• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing)
• Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the functi

Distribution: ubuntu 20.04 focal
Python : 3.8.10
CUDA:11.4.315
cuDNN :8.6.0.166
TensorRT :8.5.2.2
VPI:2.2.7
OpenCV:4.5.4
Model:NVIDIA Orin NX Developer Kit
Module:NVIDIA Jetson Oriin NX(16GB ram)
Jetpack:5.1.1
DeepStream: 6.2

Can the normal pipleline works well? for example the pipeline below:
gst-launch-1.0 filesrc location=/opt/nvidia/deepstream/deepstream/samples/streams/sample_1080p_h264.mp4 ! qtdemux ! queue ! h264parse ! nvv4l2decoder ! fakesink

nvv4l2decoder element support dynamic resolution.

But you need renegotiation the pipeline. Here is a sample from gstreamer.
You can refer it, I have tried,It could be work.

Hello, this pipeline is running normally.

Hello, I tried the following pipeline but it still didn’t work. I renegotiated it by modifying capsfilter_caps.
appsrc ! h264parse ! capsfilter ! nvv4l2decoder ! appsink
I can achieve the desired effect through soft decoding avdec_h264 Example pipeline:
appsrc ! h264parse ! avdec_h264 ! appsink
The above pipeline can output data without any operation, but when using nvv4l2decoder, the entire pipeline will stop reading data when the resolution of the pipeline changes.

There are many differences between software decoders and hardware decoders due to the video memory involved.

Changing resolution causes memory reallocation.

Make sure the below command line can run normally.

filesrc ! h264parse ! capsfilter ! nvv4l2decoder ! nv3dsink

then try the following 2 commands to see if the problem is caused by appsrc/appsink.

appsrc ! h264parse ! capsfilter ! nvv4l2decoder ! nvvideoconvert ! video/x-raw, format=NV12 ! filesink location=out.yuv

filesrc ! h264parse ! capsfilter ! nvv4l2decoder ! appsink

Thank you very much for your support. After upgrading the video generation SDK, I used this pipeline to test dynamically changing the resolution successfully.

Hello, I found out when piping appsrc ! h264parse ! capsfilter nam=resolution ! nvv4l2decoder ! nvvidecoconvert ! video/x-raw,format=I420,width=1920,height=1080 ! filesink location=./out.yuv After switching the resolution, characters in the video stream will cause ghosting.
As shown in the figure, the partial effect:
Snipaste-2023-09-20-14-26-04.png

I can’t open this image. But I guess this problem is caused by the scaling of nvvideoconvert

You can try nvvideoconvert compute-hw=1 to use GPU scaling.
and interpolation-method=2 use another scaling algorithm

use gst-inspect-1.0 nvvideoconvert to get more information.

Hello, when compute-hw=1 is set, an action will jump repeatedly in the stream.

Sorry, there was something wrong with the way I uploaded the picture yesterday. Here are the related pictures.
image.zip (296.1 KB)

Ok, Maybe bug of version 6.2, I have tried following command on version 6.3, It’s ok.

gst-launch-1.0 filesrc location=/opt/nvidia/deepstream/deepstream/samples/streams/sample_720p.h264 ! h264parse ! nvv4l2decoder ! nvvideoconvert compute-hw=1 ! video/x-raw,format=NV12 ! filesink location=out.yuv 

If Ignore the issuse of images out of order, Are the characters clear?

If use GPU can resolve this problem, You can try upgrade to DS-6.3.

  interpolation-method: Set interpolation methods
                        flags: readable, writable, controllable
                        Enum "GstNvInterpolationMethod" Default: 6, "Default"
                           (0): Nearest          - Nearest
                           (1): Bilinear         - Bilinear
                           (2): Algo-1           - GPU - Cubic, VIC - 5 Tap
                           (3): Algo-2           - GPU - Super, VIC - 10 Tap
                           (4): Algo-3           - GPU - LanzoS, VIC - Smart
                           (5): Algo-4           - GPU - Ignored, VIC - Nicest
                           (6): Default          - GPU - Nearest, VIC - Nearest

After Change the value of interpolation-method, Has the problem improved?

Hello, my current environment does not support 6.2 yet. Is there any relevant dynamic library that can be directly replaced?

Hello, I want to know how the nvv4l2decoder elements should be renegotiated, I am still stuck after trying capsfilter !nvv4l2decoder to change capsfilter _caps

Now let’s do some experiments.

1.Make a 720p stream

ffmpeg -i /opt/nvidia/deepstream/deepstream/samples/streams/sample_720p.mp4 -vf "drawtext=text='720p':fontcolor=red:x=200:y=200:font=Arial" -video_size 1280x720 -vcodec h264 720.h264

2.Make a 1080p stream

ffmpeg -i /opt/nvidia/deepstream/deepstream/samples/streams/sample_720p.mp4 -vf "drawtext=text='1080p':fontcolor=red:x=200:y=200:font=Arial" -video_size 1920x1080 -vcodec h264 1080.h264

3.Misc both them

cat 720.h264 1080.h264 > misc.h264

4.Play it use gstreamer with nvv4l2decoder

gst-launch-1.0 filesrc location="your misc.h264 path" ! h264parse ! nvv4l2decoder ! nv3dsink

If caps are not modified, nvv4l2decoder can also handle dynamic resolution.

If your resolution changes, please add sps/pps when changing

Hello, I tested that the above command can be used. Is this related to the GDR encoding of my stream? I have set enable-frame-type-reporting=TRUE

What is GDR and enable-frame-type-reporting ? That doesn’t look like a property of nvv4l2h264enc.

You need encode IDR coded picture after changing the resolution usually.

Hello, this attribute is an attribute of nvv4l2decoder. I used to need to add this parameter when parsing the stream encoded by H264 GDR.

My video stream will send SPS PPS IDR frames after switching resolutions