Tee: display and filesink - freezing display

I’m trying to use tee to display my webcam captured video while save it to mp4 file.

Doing it separately, capture and display video works:
gst-launch-1.0 -e -v v4l2src num-buffers=300 device=/dev/video0 ! video/x-raw, format=YUY2, width=640, height=480, framerate=30/1 ! autovideosink

also works to save file separately:
gst-launch-1.0 -e -v v4l2src num-buffers=300 device=/dev/video0 ! video/x-raw, format=YUY2, width=640, height=480, framerate=30/1 ! videoconvert ! video/x-raw,format=NV12 ! x264enc ! mp4mux ! filesink location=my.mp4

But if put these two together with tee, the display freeze (only 1st still image shown) -
gst-launch-1.0 -e -v v4l2src num-buffers=300 device=/dev/video0 ! video/x-raw, format=YUY2, width=640, height=480, framerate=30/1 ! tee name=t ! queue ! autovideosink t. ! queue ! videoconvert ! video/x-raw,format=NV12 ! x264enc ! mp4mux ! filesink location=my.mp4

Any insight what is wrong here?
Any help is much appreciated!
Jim

Hi Jim,

It appears that the queue going to the autovideosink branch is getting full and therefore blocking the whole pipeline (this is caused by the videosink remaining in PAUSED state).

You can fix this by adding leaky=downstream to the 1st queue so once it’s full it drops any old buffers. Or alternatively, you can use xvimagesink async=false which avoids the PAUSED issue.