[code] [blog] [VNC] [E-Mail me] [GPS Tracker]

NoVNC with audioOctober 26 2020 23:32:43

Portability is very useful - and I like being able to take my workspace everywhere. For a while now I've had a VPS with the german provider Contabo - and so far I've only used it for shell access. Of course I'm running Gentoo so transforming the server to a fully fledged virtual desktop isn't too difficult - just emerge all the relevant packages and start tigervnc.


Of course if everything was this easy - I wouldn't be writing a blog post about it. While tigervnc has sensible defaults on Gentoo - and getting a working VNC connection is fairly easy next comes the tough part - access. For this I've installed noVNC. When installed on a webserver this VNC client allows you to access your VNC server through a webbrowser. This VNC server however has some shortcomings - like all VNC servers it does not support audio streaming. A bit of googling reveals that people are already experimenting with audio support.


Of course things aren't as straight-forward as they seem - the code in this pull request has a few flaws. The first one being that I mainly work on a Macbook nowadays - and they do not support webm audio. To enable audio support that works on any computer I've used the older mp4 audio stream format. Furthermore I've written a small program in c that pipes the output from a pulse sink to a tcp socket. This is then piped through websockify and streamed to the client. With this I've achieved low-latency audio support for any modern browser :) Here is the end result, gentoo in my browser - indistinguishable from the real thing.


In order to achieve this look I've modified the files for NoVNC-lite, added automatic reconnects and a small menu bar for display quality settings - and added the files "vnc.js" and "webaudio.js". Webaudio is the implementation of the audio stream - and vnc.js contains the methods neccesary to invoke it. When you press your first key in the remote desktop environment - the webpage catches the event and starts the audio stream. This because I had to work around the fact that audio streams cannot be started automatically without user input in current browsers.
That's it - I've enjoyed writing this code - and I hope it's useful for others too. It's free software, so use it as you like.


Update ( 31 oct 2020 ): I've updated websockify to support current SSL methods and fixed copy-paste for VNC servers without clipboard. See novnc_current.zip below.



File post.zip
Size 160.21kB
crc32 3440861983
md5 eef768f48fc27677226e33f349d064f7
sha512 90fcde711f7696f721921cf122f8750714bedafd7b5141bbcdcada92f4ce450c9b6a9a2f96898ab3c4fd6104fa1ea6db7f4673d4f5075e3d1bfffbe5bbed8f43
File novnc_current.zip
Size 161.03kB
crc32 3730061291
md5 625c9f84454c393738c848e38563d330
sha512 0eff0c7856281c3998d5ebea84d0fa581ef1b043638053d45be53b58e53f973672e7e56199ec4bb8825c16e7f98ca41d3e0bd68486b6e6fd51735ecabe0082eb