# Wrong frame order when decoding the stream on GPU

**URL:** <https://forums.developer.nvidia.com/t/wrong-frame-order-when-decoding-the-stream-on-gpu/112841>\
**Category:** DeepStream SDK\
**Created:** [February 28, 2020, 12:31pm UTC](https://forums.developer.nvidia.com/t/wrong-frame-order-when-decoding-the-stream-on-gpu/112841 "2020-02-28T12:31:43Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![amjad.akkawi](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@amjad.akkawi](https://forums.developer.nvidia.com/u/amjad.akkawi)\
**Post date:** [February 28, 2020, 12:31pm UTC](https://forums.developer.nvidia.com/t/wrong-frame-order-when-decoding-the-stream-on-gpu/112841/1 "2020-02-28T12:31:43Z")

</div>

We are getting wrong frame order on the decoding streams on GPU. On CPU the order seems to be OK.

Nvidia Driver: 418.87  
Deepstream: 3.0  
Video SDK: 9.0.20  
Deepstreamer: 1.8.3

Command:  
gst-launch-1.0 nvstreammux name=mux width=544 height=544 batch-size=16 ! fakesink   
uridecodebin uri=‘file:///storage/ext\_media/sochi\_wedding\_1.h264’ ! nvvidconv ! ‘video/x-raw(memory:NVMM)’ ! videorate ! ‘video/x-raw(memory:NVMM), format=NV12, framerate=10/1’ ! queue name=q0 ! mux.sink\_0   
uridecodebin uri=‘file:///storage/ext\_media/sochi\_wedding\_1.h264’ ! nvvidconv ! ‘video/x-raw(memory:NVMM)’ ! videorate ! ‘video/x-raw(memory:NVMM), format=NV12, framerate=10/1’ ! queue ! tee name=t   
t. ! queue ! mux.sink\_1   
t. ! queue ! nvvidconv ! ‘video/x-raw’ ! videorate ! ‘video/x-raw, framerate=10/1’ ! videoscale ! ‘video/x-raw, width=640, height=360’ ! jpegenc quality=23 ! multifilesink location=‘/storage/ext\_media/out\_dir/image\_%d.jpg’

In my opinion the problem is with the “tee” plugin - one of its consumers is really fast (jpegenc and multifilesink) and the other (nvstreammux) waits for 16 frames before consuming the data (this is controlled by the “batch-size” parameter of nvstreammux). Reducing this parameter to 4 or 2 solves the problem, but it is not a viable option for us - later modules work optimally with batch-size of 32. Note that for 2 streams (i.e. using the command above) the pipeline gets stuck in PREROLLING if we set batch-size to 32.

I checked the timestamps of the buffers arriving to the jpegenc element and they have the right pts.  
So indeed it looks like buffers being rewritten while travelling through the pipeline.

According to my tests, nvidia’s elements are not using the ALLOCATION query to compute the number of decoder output buffers.  
The decoder seems to always allocates 4 buffers, regardless of the pipeline topology and nvstreammux is not even responding to the allocation query:  
0:00:00.495817443 1831 0x16eaa80 DEBUG tee gsttee.c:617:gst\_tee\_query\_allocation: Allocation query failed on pad src\_0, ignoring allocation

I generated a graph of your full pipeline for easier visualization see attached

 ![nv-pipeline.png](https://global.discourse-cdn.com/nvidia/original/2X/6/67d9d1effb0b9cfae457e65c8b239a6cc3eacb4e.png)

---

<div class="post-metadata">

**Author:** ![Amycao](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/amycao/32/11342_2.png) [@Amycao](https://forums.developer.nvidia.com/u/Amycao)\
**Post date:** [March 5, 2020, 8:20am UTC](https://forums.developer.nvidia.com/t/wrong-frame-order-when-decoding-the-stream-on-gpu/112841/2 "2020-03-05T08:20:29Z")

</div>

HI  
Sorry for a late reply, can you use DS 4.0.2 for a try instead of 3.0?

---

<div class="post-metadata">

**Author:** ![kayccc](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/kayccc/32/14043_2.png) [@kayccc](https://forums.developer.nvidia.com/u/kayccc)\
**Post date:** [March 17, 2020, 5:28am UTC](https://forums.developer.nvidia.com/t/wrong-frame-order-when-decoding-the-stream-on-gpu/112841/3 "2020-03-17T05:28:10Z")

</div>

Hi amjad.akkawi,

Please try with DS 4.0.2, if still an issue, please open a new topic.

Thanks

---

<div class="post-metadata">

**Author:** ![trild-vietnam](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/trild-vietnam/32/126326_2.png) [@trild-vietnam](https://forums.developer.nvidia.com/u/trild-vietnam)\
**Post date:** [April 17, 2020, 9:39am UTC](https://forums.developer.nvidia.com/t/wrong-frame-order-when-decoding-the-stream-on-gpu/112841/4 "2020-04-17T09:39:07Z")

</div>

Hello kayccc,

I faced still the issue, with DS 4.0.2 please check it.

---

<div class="post-metadata">

**Author:** ![amjad.akkawi](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@amjad.akkawi](https://forums.developer.nvidia.com/u/amjad.akkawi)\
**Post date:** [April 17, 2020, 4:49pm UTC](https://forums.developer.nvidia.com/t/wrong-frame-order-when-decoding-the-stream-on-gpu/112841/5 "2020-04-17T16:49:05Z")

</div>

I faced it also with DS 4.02.

---

<div class="post-metadata">

**Author:** ![Amycao](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/amycao/32/11342_2.png) [@Amycao](https://forums.developer.nvidia.com/u/Amycao)\
**Post date:** [April 21, 2020, 4:17am UTC](https://forums.developer.nvidia.com/t/wrong-frame-order-when-decoding-the-stream-on-gpu/112841/6 "2020-04-21T04:17:57Z")

</div>

Can you specify details how you see frame order wrong on the decoding streams on GPU?

---

<div class="post-metadata">

**Author:** ![amjad.akkawi](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@amjad.akkawi](https://forums.developer.nvidia.com/u/amjad.akkawi)\
**Post date:** [May 10, 2020, 11:46am UTC](https://forums.developer.nvidia.com/t/wrong-frame-order-when-decoding-the-stream-on-gpu/112841/7 "2020-05-10T11:46:00Z")

</div>

> [@Amycao](#):
>
> decoding

In the original ticket i put the command i used and then manually viewed the images . Here is the command again:

Command:  
gst-launch-1.0 nvstreammux name=mux width=544 height=544 batch-size=16 ! fakesink  
uridecodebin uri=‘file:///storage/ext\_media/sochi\_wedding\_1.h264’ ! nvvidconv ! ‘video/x-raw(memory:NVMM)’ ! videorate ! ‘video/x-raw(memory:NVMM), format=NV12, framerate=10/1’ ! queue name=q0 ! mux.sink\_0  
uridecodebin uri=‘file:///storage/ext\_media/sochi\_wedding\_1.h264’ ! nvvidconv ! ‘video/x-raw(memory:NVMM)’ ! videorate ! ‘video/x-raw(memory:NVMM), format=NV12, framerate=10/1’ ! queue ! tee name=t  
t. ! queue ! mux.sink\_1  
t. ! queue ! nvvidconv ! ‘video/x-raw’ ! videorate ! ‘video/x-raw, framerate=10/1’ ! videoscale ! ‘video/x-raw, width=640, height=360’ ! jpegenc quality=23 ! multifilesink location=’/storage/ext\_media/out\_dir/image\_%d.jpg’

---

<div class="post-metadata">

**Author:** ![rsc44](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@rsc44](https://forums.developer.nvidia.com/u/rsc44)\
**Post date:** [May 10, 2020, 6:42pm UTC](https://forums.developer.nvidia.com/t/wrong-frame-order-when-decoding-the-stream-on-gpu/112841/8 "2020-05-10T18:42:52Z")

</div>

@amjad.akkawi

Why are you saving the images before streammux ? Have you tried using demux ? I can verify that it will work if you try and save the images after demux.

Pro-tip: If you want to save images before streammux i recommend using interpipesrc/interpipesink. I can verify that will save the images in the correct order if you dont want to use demux.

---

<div class="post-metadata">

**Author:** ![Amycao](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/amycao/32/11342_2.png) [@Amycao](https://forums.developer.nvidia.com/u/Amycao)\
**Post date:** [May 12, 2020, 2:40am UTC](https://forums.developer.nvidia.com/t/wrong-frame-order-when-decoding-the-stream-on-gpu/112841/9 "2020-05-12T02:40:13Z")

</div>

I see your commands, but how you verify frame order wrong?

---

<div class="post-metadata">

**Author:** ![TomNVIDIA](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/tomnvidia/32/14181_2.png) [@TomNVIDIA](https://forums.developer.nvidia.com/u/TomNVIDIA)\
**Post date:** [October 12, 2021, 4:17pm UTC](https://forums.developer.nvidia.com/t/wrong-frame-order-when-decoding-the-stream-on-gpu/112841/10 "2021-10-12T16:17:52Z")

</div>

Closed on October 12, 2021, 4:17pm UTC


