These quarantine days I was going to share my desktop to friends to explain them what is git in a practice. The problems are:
- I use FreeBSD.
- We are behind NATs. But I've got a VPS with VPN (Wireguard) configured for these purposes.
- I want to use free and simple ("suckless") softwares.
What I decided to use is to share my desktop with ffmpeg -f x11grab and stream output to any port. As we can be in one virtual network, friends could watch this stream without problems using any VLC, MPV or web-browser. The problem came when I understood that ffmpeg cannot output directly to http. I tried a lot of solutions like sending via rtmp to YouTube Live Streaming (overhead and not a free service) and splitting and sharing with HLS protocol and HTTP server and stopped at HLS.
My ffmpeg launching:
ffmpeg -f x11grab -video_size 1920x1080 -i :0 -c:v h264 -f hls -hls_time 1 -g 15 stream.m3u8
And mpv with which I'm testing:
mpv --no-cache --no-resume-playback stream.m3u8
I see that there is a latency about 10-15 seconds. Even if I set video bitrate to a half of megabyte there is a similar latency (and bad quality of course) so that can mean the problem is not in a bandwidth [and I didn't even start to broadcast it somewhere further than my local PC!].
I found a SO answer where a user says HLS is a wrong protocol for low latency. I read many blogs, Wikipedia articles and ffmpeg Wikipedia (StreamingGuide) but couldn't find a solution. How can I reduce a latency or what software instead can I use (ffmpeg is preferable) to let my friends to see my desktop with a latency equals to few seconds like Discord and Skype does? It's worth to say: I don't need a good quality and drops are ok because I'm going to share a terminal window.