encodinggstreamerrtpvncrfb-protocol

VNC screen live streaming with GStreamer


Intro

I've been trying to capture vnc screen with GStreamer and then send it to rtp endpoint. I've already used a rfbsrc plugin, but it works unstable and there are first frames loss and freezing. Maybe there is an issue in my GStreamer pipeline :

'--gst-debug=2',
'-vvv',
'rtpbin', 'name=rtpbin', 'rtp-profile=avpf', 'latency=100',
'rfbsrc', `host=${rfbConfig.host}`, `port=${rfbConfig.port}`,
'!', 'videoconvert',
'!', 'x264enc', 'tune=zerolatency', 'speed-preset=1', 'dct8x8=true', 'quantizer=23', 'pass=qual',
'!', 'video/x-h264, profile=baseline',
'!', 'rtph264pay', 'ssrc=111110', 'pt=96',
'!', 'queue2',
'!', 'rtprtxqueue', 'max-size-time=2000', 'max-size-packets=0',
'!', 'rtpbin.send_rtp_sink_0',
'rtpbin.send_rtp_src_0',
'!', 'udpsink', 'bind-address=127.0.0.1', 'host=127.0.0.1', 'bind-port=5004', `port=${videoRtpPort}`,
'rtpbin.send_rtcp_src_0',
'!', 'udpsink', 'bind-address=127.0.0.1', 'host=127.0.0.1', `port=${videoRtcpPort}`, 'sync=false', 'async=false', 'udpsrc', 'port=5005',
'!', 'rtpbin.recv_rtcp_sink_0',

I'm trying to use another way of capturing - to encode frames from stdin, but actually I've succeeded nothing with the following pipeline:

'--gst-debug=2',
'-vvv',
'rtpbin', 'name=rtpbin', 'rtp-profile=avpf', 'latency=100',
'fdsrc',
'!', 'videoparse', 'width=1280', 'height=720', 'framerate=15/1',
'!', 'queue',
'!', 'x264enc', 'tune=zerolatency', 'speed-preset=1', 'dct8x8=true', 'quantizer=23', 
'pass=qual',
'!', 'video/x-h264, profile=baseline',
'!', 'rtph264pay', 'ssrc=111110', 'pt=96',
'!', 'queue2',
'!', 'rtprtxqueue', 'max-size-time=2000', 'max-size-packets=0',
'!', 'rtpbin.send_rtp_sink_0',
'rtpbin.send_rtp_src_0',
'!', 'udpsink', 'bind-address=127.0.0.1', 'host=127.0.0.1', 'bind-port=5004', 
`port=${videoRtpPort}`,
'rtpbin.send_rtcp_src_0',
'!', 'udpsink', 'bind-address=127.0.0.1', 'host=127.0.0.1', `port=${videoRtcpPort}`, 
'sync=false', 'async=false', 'udpsrc', 'port=5005',
'!', 'rtpbin.recv_rtcp_sink_0',

The question

What is the correct way to capture vnc screen with GStreamer and send in to RTP endpoint? Is there any explicit mistake in my GStreamer pipelines?


Solution

  • Finally, I solved the issue with the following pipeline:

    'gst-launch-1.0',
    '-vvv',
    'rtpbin', 'name=rtpbin', 'rtp-profile=avpf',
    'fdsrc', 'timeout=1000000',
    '!', 'queue', 'max-size-bytes=0', 'max-size-buffers=0', 'max-size-time=0', 'min-threshold-buffers=1',
    '!', 'image/x-portable-pixmap,width=1280,height=720,framerate=30/1',
    '!', 'pnmdec',
    '!', 'videoconvert',
    '!', 'x264enc', 'tune=zerolatency', 'speed-preset=1', 'dct8x8=true', 'quantizer=23', 'pass=qual',
    '!', 'video/x-h264, profile=baseline',
    '!', 'rtph264pay', 'ssrc=111110', 'pt=96',
    '!', 'rtprtxqueue', 'max-size-time=2000', 'max-size-packets=0',
    '!', 'rtpbin.send_rtp_sink_0',
    'rtpbin.send_rtp_src_0',
    '!', 'udpsink', 'bind-address=127.0.0.1', 'host=127.0.0.1', 'bind-port=5004', `port=${videoRtpPort}`,
    'rtpbin.send_rtcp_src_0',
    '!', 'udpsink', 'bind-address=127.0.0.1', 'host=127.0.0.1', `port=${videoRtcpPort}`, 'sync=false', 'async=false', 'udpsrc', 'port=5005',
    '!', 'rtpbin.recv_rtcp_sink_0',
    

    I used pnmdec to decode raw images got from rfb (vnc).