Hello HN,
In the university I'm working in, they have asked me to produce a remote desktop stream for students to connect to and watch the professor coding on his desktop. I would like to use FFMPEG with the latest AVI1 capabilities since we have some gpus (it would be great to use them). 'They' would like a native solution (testing me). I'm looking for information where I can learn to do that elegantly.<p>Thanks HN, much love
What latency are you trying to do? Will the professor being communicating with the students while doing this? Will the students all have the same bandwidth, or will you want multiple renditions (low, med, high quality levels)?<p>If you want AV1 you will not be able to use RTMP. The protocol is orphaned/deprecated, so avoid if possible!<p>If I was building it this is what I would do, and my reasoning.<p>* For capture + encoding I would use OBS. You will want to use something that is easy for users to install configure. Professors will also have lots of custom requirements when it comes to layout etc... it will be tempting to do a ffmpeg command directly, but it will fall apart quick I believe.<p>* To get AV1 out of OBS I would use FFMPEG output. I would have it send RTP. RTP is used to carry video in a sub-second manner. This is the same protocol that WebRTC uses. You know have AV1 + low latency.<p>* Then for users to watch I would use WebRTC. That will allow them to watch in their web browser. Conceptually it will be like this <a href="https://github.com/pion/webrtc/tree/master/examples/rtp-to-webrtc" rel="nofollow">https://github.com/pion/webrtc/tree/master/examples/rtp-to-w...</a> this takes the RTP packets and puts them in the browser.<p>Lots of great projects exist that you could use for 'RTP -> WebRTC' like <a href="https://galene.org/" rel="nofollow">https://galene.org/</a> and <a href="https://livekit.io/" rel="nofollow">https://livekit.io/</a> I would suggest checking them all out!<p>If you have more questions/want to talk to people in the video space always happy to chat on <a href="https://pion.ly/slack" rel="nofollow">https://pion.ly/slack</a> :)
OME [1] is a RTMP server for sub-second WebRTP streaming. Profiles allow for specific encodes if needed. I have a repository hosting an exemplary configuration and a frontend using their player [2].<p>Another server is SRS [3], but IMO it is more difficult to use, lacks features and the delay is about 1-3s — it requires far less bandwidth though.<p>[1] <a href="https://github.com/AirenSoft/OvenMediaEngine" rel="nofollow">https://github.com/AirenSoft/OvenMediaEngine</a>
[2] <a href="https://github.com/hashworks/simple-ome" rel="nofollow">https://github.com/hashworks/simple-ome</a>
[3] <a href="https://github.com/ossrs/srs" rel="nofollow">https://github.com/ossrs/srs</a>
I would also recommend OBS as another commentator has mentioned. I believe in both cases you will need an RTSP server to handle multiple client connections.<p>I looked into a similar ffmpeg solution a couple of months ago and broadcast an libx264 video only stream with ~1 second latency to an rtsp server: <a href="https://gist.github.com/andrewmackrodt/88c2233fb9cc4797ada93e6703c13d72" rel="nofollow">https://gist.github.com/andrewmackrodt/88c2233fb9cc4797ada93...</a><p>However, I found this solution to be too CPU intensive as I was unsure if/how to instruct x11grab to interact with the GPU directly. Perhaps if I used my nvidia card for encoding it would have been more performant. However, OBS makes this entire process much easier.
I had been doing Twitch streaming seven years ago (so, RTSP, if I recall correctly) with an ffmpeg script I wrote.<p><a href="https://github.com/tcarrio/ffmpeg-streamcast/blob/master/bash_progress.sh#L1" rel="nofollow">https://github.com/tcarrio/ffmpeg-streamcast/blob/master/bas...</a><p>Also, seven years, and I eventually ended up moving to OBS instead of diving even further, but that was working at the time.<p>However, it won't give you any pointers for using AV1, and this is just the streaming source, you'll still need an RTSP server and clients to access them.
I'm not sure if this is what you are looking for, but have you tired <a href="https://obsproject.com/" rel="nofollow">https://obsproject.com/</a> Warning: It has too many options, so it takes a while to get the correct configuration. Also, the difference between "Stopped" and "Recording" is too subtle, so I had to modify the layout style to make it foolproof for me.
Check out Galene:<p><a href="https://galene.org/" rel="nofollow">https://galene.org/</a><p>I don't think it uses ffmpeg, but it may have the features you are looking for
I was able to use fauxstream as a starting point for part of my streaming project.<p>My experiment was streaming via a ipfs transport layer.<p>fauxstream is a very thin wrapper around ffmpeg, it proved invaluable in providing a reference command I could iterate off of to get my stream working.<p><a href="https://github.com/rfht/fauxstream" rel="nofollow">https://github.com/rfht/fauxstream</a><p>edit: it is hard to tell what op wants but it could be as simple(hah, the ffmpeg command line terrifies me) as<p>stream caster:
ffmpeg -video_size 1280x720 -f x11grab -i :0 -r 30 -c:v libx264 -vb 3500k -minrate 3500k -maxrate 3500k -bufsize 7000k -preset ultrafast -vf format=yuv420p -g 60 -keyint_min 30 -f flv - | nc -l 1234<p>stream viewer:
nc stream_caster 1234 | ffplay -
If you need real time, eg. Teacher interaction in chat with the students I recommend WebRTC. Try to take a look at something like LiveKit, or if you need a little more low level control Pion.
Experiment with gstreamer as well.<p>If you're after very low latency, then try Mjpeg. Most modern compressions are temporal, there will always be a several frames lag.
For the streaming client I wouldn't reinvent the wheel and go with OBS Studio.<p>Now do you have a streaming server, where the students will connect to? If not you can put something simple together with nginx and RTMP.
You should realize that you are describing two separate problems:<p><pre><code> * how to create content for a stream
* how to broadcast that stream to viewers
</code></pre>
Which one are you trying to solve?