4

I'm looking for a way to duplicate my desktop on a network. (Something that would work on a web browser client would be amazing.)

  • I tried to use vnc / x11vnc but quality/framerate is too low. (cpu too high on smartphone client - I think.)

  • I tried to transform the screen into a streaming video with ffmpeg but i couldn't do it. (bad quality and not real streaming system)

Is there a way to do that ? Maybe by using X11 forwarding and duplicate screen ?

A mix of ssh -X and xrandr -d :0 --output HDMI-1 --auto maybe ? (This xrandr code duplicate screen on HDMI-1)

Like : xrandr -d :0 --output http://192.168.1.3:9001 --auto (I'm dreaming.)

EDIT : Maybe xpra can do what I'm looking for ? But I can't make it work for now.

  • Do you need to interact with the screen as well or just display/stream it? – rudib Dec 17 '18 at 13:14
  • just display is enough (duplicate screen) read-only – bob dylan Dec 17 '18 at 14:14
  • just like if it was another screen with the same output – bob dylan Dec 17 '18 at 14:23
  • xpra seems to be more for individual applications that are invoked from the remote side. I'm usure if that's what you want. Did you try the improved ffmpeg command? An alternative could be something like NX (a remote desktop application, see e.g. NoMachine). Remote desktop applictations may be more optimised in regards of latency. However note that the person on the other end can interact with your machine. This should also be the case with xpra. – rudib Dec 20 '18 at 21:17
  • Yeah.. but high cpu usage, low quality, low fps. I was really hoping for more... Using more network, less cpu. – bob dylan Dec 23 '18 at 11:44
3
+25

You could use ffmpeg for that:

On the transmitting device, run:

ffmpeg -f x11grab -s 1800x1000 -framerate 30 -i :0.0 -preset fast -vcodec libx264 -tune zerolatency -b 900k -f mpegts udp://RECEIVERIP:9000

And on the receiving device, open the firewall port 9000/UDP and run:

ffplay udp://@:9000

You need to set RECEIVERIP accordingly, as well as adjust the area of the screen you want to transmit by modifying -s 1800x1000. Of course, you can choose any free port you want instead of 9000.

Performance-wise you can adjust -framerate and -preset (...|fast|ultrafast) as far as your transmitting machine can handle while maintaining the quality and latency you need.

ffplay is a very minimal client that may fit your needs. You could also use vlc.

To display the stream on a browser, you would probably have to use a streaming server in addition. vlc would have that capability, but it may be slow and I didn't find suffucient documentation for that yet.

Notes:

An optimised transmitting command (for lower latency, but lower quality and not especially dynamic content) may look like this:

ffmpeg -f x11grab -s 1800x1000 -framerate 15 -i :0.0 -preset ultrafast -vcodec libx264 -tune zerolatency -b 500k -f mpegts udp://RECEIVERIP:9000

To further optimise the load, you can leverage hardware acceleration, as documented. While this is platform dependent, it might significantly decrease the CPU load if supported.

  • 1
    I appreciate the full example. I tried to use this but the cpu usage is way too high, ~30% with ultrafast. And there is delay of about 3 seconds. – bob dylan Dec 19 '18 at 9:31
  • tested it on localhost 127.0.0.1 – bob dylan Dec 19 '18 at 9:39
  • Unfortunately, you can't completely eliminate the CPU load. Decreasing the bitrate -b 900k should also decrease the load a bit. Of course the frame rate of 30 FPS may also be too high for your machine. I'm not sure what exactly you want to transmit, so dropping the frame rate drastically may make sense or not. If you want to transmit dynamic content (e.g. video), that would require a high frame rate or it would be chopped up. But if the image is not expected to change rapidly, you could try 20 or 15 FPS. – rudib Dec 19 '18 at 10:55
  • I've updated my answer with an example (optimised for lower latency, lower quality and not especially dynamic content) that reduced the load on my machine to about 15-20% avg. Unfortunately, you can't really compare that. – rudib Dec 19 '18 at 12:44
2

Chrome Remote Desktop is probably what you are looking for:

https://chrome.google.com/webstore/detail/chrome-remote-desktop/gbchcmhmhahfdphkhkmpfmihenigjmpp?hl=en

  • Interesting but it is very similar to vnc. (better than vnc I have to admit) But I was only able to create a new session with exec /usr/bin/startxfce4 in ~/.chrome-remote-desktop-session. Do you know how to duplicate screen from my laptop / read only ? – bob dylan Dec 19 '18 at 9:24
  • See here: support.google.com/chrome/answer/1649523 at the section "Share your computer with someone else" and "Access a computer remotely" – V13 Dec 19 '18 at 22:57
  • I still don't know how to duplicate a screen, i just have another session. – bob dylan Dec 23 '18 at 11:45
  • So, do you know how to duplicate the output of an existing session ? – bob dylan Jan 6 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.