Gstreamer tee usage for appsink and filesink with nvivafilter processing

I’m trying to use camera’s frames for appsink and filesink.
here is the current code working well.

pipeline

gst-launch-1.0 -v pylonsrc camera=0 fps=30 imageformat=ycbcr422_8 gamma=1.10001 gain=9.2 exposure=11000 
! queue ! nvvidconv ! 'video/x-raw(memory:NVMM)' 
! queue ! nvivafilter customer-lib-name=./lib-gst-custom-opencv_cudaprocess0.so cuda-process=true 
! queue ! 'video/x-raw(memory:NVMM), format=RGBA' 
! queue ! nvegltransform ! nveglglessink

pipeline in program

"pylonsrc camera=0 fps=30 imageformat=ycbcr422_8 gamma=1.10001 gain=9.2 exposure=11000 "
      "! queue ! nvvidconv "
      "! video/x-raw(memory:NVMM) "
      "! queue ! nvivafilter customer-lib-name=../cu/lib-gst-custom-opencv_cudaprocess0.so cuda-process=true "
      "! queue ! video/x-raw(memory:NVMM), format=RGBA "
      "! queue ! nvvidconv "
      "! video/x-raw "
      "! queue ! appsink name=sink sync=false ";

However if I add tee method to record original camera’s frames at the same time, it doesn’t work well with error bellow.

error

WARNING: erroneous pipeline: could not link t to queue1, t can't handle caps video/x-raw, format=(string)I420

pipeline

gst-launch-1.0 -v pylonsrc camera=0 fps=30 imageformat=ycbcr422_8 gamma=1.10001 gain=9.2 exposure=11000 
! queue ! nvvidconv ! 'video/x-raw(memory:NVMM)' 
! tee name=t ! 'video/x-raw, format=(string)I420' 
! queue ! 'video/x-raw, format=(string)I420' ! omxh265enc ! matroskamux filesink location =test.mp4 t. 
! queue ! nvivafilter customer-lib-name=./lib-gst-custom-opencv_cudaprocess0.so cuda-process=true 
! queue ! 'video/x-raw(memory:NVMM), format=RGBA' 
! queue ! nvegltransform ! nveglglessink

I was searching and trying with modifications, but still doesn’t work. maybe I didn’t understand its usage well.

Could you guys have any advises?
Thank you.

You may try something like :

gst-launch-1.0 videotestsrc is-live=true ! nvvidconv ! 'video/x-raw(memory:NVMM), format=NV12' ! tee name=t ! 'video/x-raw(memory:NVMM), format=NV12' ! queue ! nvivafilter cuda-process=true ! 'video/x-raw(memory:NVMM), format=RGBA' ! nvegltransform ! nveglglessink     t. ! queue ! 'video/x-raw(memory:NVMM), format=NV12' ! omxh265enc ! h265parse ! matroskamux ! filesink location=test_h265.mkv

If this works, just change the beginning for using pylonsrc instead of videotestsrc.

it worked fine.

so it needs to be same format before and after calling tee.

Thank you.