Search code examples
linuxcameragstreamergstreamer-1.0

When the image size is large, the GStreamer pipeline using shmsink and shmsrc stops


I want to transfer large images through shared memory. When I send a 4000x3000 pixel image using shmsink and shmsrc in GStreamer, the image stops after a few frames are displayed. However, it doesn't crash, just the image stops. There are no error messages.

This is the command for send.

gst-launch-1.0 v4l2src device=/dev/video0 \
! "video/x-raw,format=(string)YUY2,width=(int)640,height=(int)480,pixel-aspect-ratio=(fraction)1/1,framerate=(fraction)30/1" \
! videoscale \
! "video/x-raw, width=(int)4000, height=(int)3000" \
! shmsink socket-path=/tmp/foo

And this is command for receive.

gst-launch-1.0 shmsrc socket-path=/tmp/foo \
! "video/x-raw,format=(string)YUY2,width=(int)4000,height=(int)3000,pixel-aspect-ratio=(fraction)1/1,framerate=(fraction)30/1" \
! xvimagesink

Here's what we tried.

  • Change the image size to 3600x2700 -> works correctly
  • Change the shmsink in the send pipeline to xvimagesink -> works correctly

I'm waiting for any advice.


Solution

  • It's solved. I added the option "wait-for-connection=false" to shmsink to prevent it from stopping.

    The receive pipeline remains unchanged, but the send pipeline is now as follows.

    gst-launch-1.0 v4l2src device=/dev/video0 \
    ! "video/x-raw,format=(string)YUY2,width=(int)640,height=(int)480,pixel-aspect-ratio=(fraction)1/1,framerate=(fraction)30/1" \
    ! videoscale \
    ! "video/x-raw, width=(int)4000, height=(int)3000" \
    ! shmsink socket-path=/tmp/foo wait-for-connection=false
    

    I didn't get the information from anywhere, I just changed all the options of shmsink and it worked by accident.

    I don't know why it worked, so if you can tell me why, I'd appreciate it.