forwarded screen stutters every several seconds

Peter Maersk-Moller pmaersk at gmail.com
Sat Jan 16 04:53:44 PST 2016


Hi Henry.

I have had similar problems with both Raspberry Pi and Raspberry Pi 2. The
problem is more significant on Raspberry Pi than the Raspberry Pi 2. The
problem mostly disappear when the stream is a video stream with moving
video. You start to notice when the video is mostly still and really become
noticeable when the video contains a full screen complicated still image.

To identify the problem I tried many different settings for x264enc without
much effect. I then simultaneously
 viewed the stream on a regular laptop and saw no of the artifacts you
describe, but kept seeing them on the Pi. So the stream is okay, but shows
artifacts on the Raspberry Pi. I then inspected RTP sequence number on the
Pi, as received over the net, but saw no real drops. Nevertheless since the
Pi 2 was doing better than the Pi, I suspected somehow it dropped some
packets somewhere in the decoding. I tried adding more buffering to the
pipeline on the Pi without any real effect. Eventually I looked at the
systems UDP receive buffer size.

You can inspect the systems UDP receive buffer by using the following
command on the RaspPi:

sudo sysctl net.core.rmem_max

Now when I enlarged the buffer size by a factor 8, 16 or 32, the problem
dissapeared. You can enlarge the buffer size by executing the following
command:

sudo sysctl -w net.core.rmem_max=1310720

If the problem persist, try doubling the buffer size etc.

To cure it permanently, you need add the command (without the sudo) to the
/etc/rc.local file (Raspian distro).
Now that cured the problem with Raspberry Pi for me, but it could be
interesting to find out why the fix is necessary when you stream video with
a complicated still image. If you look at the output from x264enc streaming
a still image, you will see very low bandwidth (no real changes) until it
needs to send an I-frame. Because it has used very little bw up until then,
it uses a lot of bytes for the I-frame and you will see a very significant
spike of bytes to transport over the network. Somehow this apparently fills
the UDP receive buffer on the Raspberry Pi beyond the point where packets
are dropped. You could also say, that your udpsrc pipeline on the Raspberry
Pi does not read the packets fast enough from the UDP socket.

Okay, admittedly my theory isn't completely waterproof, there are some
holes you can punch in it, but I believe there might be a minor problem
with the udpsrc problem of gstreamer where it does not read the UDP packets
of a *complete frame fast enough* under certain conditions. Enlarging the
systems UDP receive buffer can compensate for this, but maybe the GStreamer
devs need to revisit the udpsrc code to see if it can read a complete frame
faster.

Best regards

Peter Maersk-Moller


On Sat, Jan 16, 2016 at 7:38 AM, henryco <fhenryco at yahoo.fr> wrote:

> Hello,
>
> I'm trying to stream the whole desktop screen from a PC to a raspberry pi
> with the following pipelines and everything is fine except for a rapid
> stuterring every several seconds : from a few seconds when something
> changes
> on the screen, to more than 10 seconds when it's static. I have tried
> various combinations involving  sync=false on both ends, use-damage=0,
> rtpjitterbuffer ... but with no success so far
>
> sender side:
>
> gst-launch-1.0 -v ximagesrc use-damage=true ! queue  ! videoconvert  !
> videoscale ! "video/x-raw,framerate=(fraction)30/1,format=(string)I420" !
> queue ! x264enc tune=zerolatency  ! queue ! rtph264pay  pt=96 ! udpsink
> host=192.168.1.19 port=5000
>
> receiver side (Rpi)
>
> gst-launch-1.0 -v udpsrc port=5000 caps="application/x-rtp,
> media=(string)video, clock-rate=(int)90000,
> encoding-name=(string)H264" ! rtpjitterbuffer ! rtph264depay ! queue !
> h264parse ! queue ! omxh264dec !
> queue ! eglglessink
>
> the only thing that removes the problem is when i give up the zerolatency
> tuning (smoothing over many frames probably makes the glitch disappear) but
> this is not an option  for me since the frame rate drops for a video (toot
> much charge for the Pi ?) and probably the latency increases much...
>
> may be there are too many queues in my pipelines, i dont know...
>
> thank you in advance for advice and comments
>
>
>
> --
> View this message in context:
> http://gstreamer-devel.966125.n4.nabble.com/forwarded-screen-stutters-every-several-seconds-tp4675279.html
> Sent from the GStreamer-devel mailing list archive at Nabble.com.
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20160116/c773629a/attachment.html>


More information about the gstreamer-devel mailing list