Pitch changes when exchanging nvarguscamerasrc with filesrc

Hi ,
When running the following pipeline:

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

Everything works and the I have the following values for the incoming frame.

*Incoming Frame*:                                                                                                                                                                                                                                                   
Mem type: 4                                                                                                                                                                                                                                               
Width: 3264, Height: 2464                                                                                                                 
Data size: 12451840                                                                                                                       
Color format: 6                                                                                                                           
Number of planes: 2                                                                                                                       
Width plane 0: 3264, Height plane 0: 2464                                                                                                 
Width plane 1: 1632, Height plane 1: 1232                                                                                                                                                                              
pitch plane 0: 3328 bytes, pitch plane 1: 3328 bytes                                                                                      
offset plane 0: 0 bytes, offset plane 1: 8257536 bytes                                                                                    
size plane 0: 8257536, size plane 1: 4194304                                                                                              
                                                                                                                         
                                                                                                                                                                                   

But when I change my pipeline to the following (thanks JimenaSalas):

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

I am getting a different pitch from the incoming frame, which leads to a sigsegv, because my algorithm is based on it having a certain pitch:

*Incoming Frame*:                                                                                                                                                                                                                                                        
Mem type: 4                                                                                                                                                                                                                                                
Width: 3264, Height: 2464                                                                                                                 
Data size: 12320768                                                                                                                       
Color format: 6                                                                                                                           
Number of planes: 2                                                                                                                       
Width plane 0: 3264, Height plane 0: 2464                                                                                                 
Width plane 1: 1632, Height plane 1: 1232                                                                                                 
Byte per pixel plane 0: 1, Byte per pixel plane 1: 2                                                                                      
pitch plane 0: 3264 bytes, pitch plane 1: 3264 bytes                                                                                      
offset plane 0: 0 bytes, offset plane 1: 8126464 bytes                                                                                    
size plane 0: 8126464, size plane 1: 4194304                                                                                              

Why is the pitch changing? As far as I understood, there are clear rules for pitch alignment and it shouldn’t change if the resolution didn’t change.

Hi,
Could you check if the layout is different?

/**
 * Specifies layout formats for \ref NvBufSurface video planes.
 */
typedef enum
{
  /** Specifies pitch layout. */
  NVBUF_LAYOUT_PITCH,
  /** Specifies block linear layout. */
  NVBUF_LAYOUT_BLOCK_LINEAR,
} NvBufSurfaceLayout;

Thanks @DaneLLL,
You are right. The frame is block linear when reading from file.
MEM Layout(0 is pitch): 1.
Is there something I can do to get it pitch aligned when reading from filesrc?

Hi,
The decoded buffers are in blocklinear and not able to be changed. One possible solution is to create NvBufSurface in pitch linear and call NvBufSurfTransform() to get the buffer in mypluygin.

1 Like

Thanks I will try your suggestion with NvBufSurfaceTransform

Hi @DaneLLL ,
The NvBufSurfTransform basically works (transformation works and transformed frame is pitch aligned), but I always get a NvBufSurfTransformError_Execution_Error after around 60 frames with the additional error text:

NvRmChannelSubmit: NvError_IoctlFailed with error code 22
NvRmPrivFlush: NvRmChannelSubmit failed (err = 196623, SyncPointIdx = 12, SyncPointValue = 0)
fence_set_name ioctl failed with 22
NvRmPrivFlush: NvRmChannelSubmit failed (err = 196623, SyncPointIdx = 12, SyncPointValue = 0)
fence_set_name ioctl failed with 22

Unfortunately there is no additional documentation, that explains the meaning of the NvBufSurfTransformError_Execution_Error = -2 error code. Can you explain the condition for this happening?

Hi,
One possible cause is that NvBufSurface are continually created and not destroyed. Please check this.

If you don’t see anything suspicious, we would need your help to share a patch to

/opt/nvidia/deepstream/deepstream-5.1/sources/gst-plugins/gst-dsexample/gstdsexample.cpp

So that we can reproduce the failure and do investigation.

1 Like

Thanks for the help, it works, I overlooked NvBufSurfaceDestroy failing.

1 Like