livekit / livekit-cli

Command line interface to LiveKit
https://docs.livekit.io
Other
228 stars 75 forks source link

Simulcast with ffmpeg #63

Open nums opened 2 years ago

nums commented 2 years ago

is it possible to publish a stream from ffmpeg with multiple bitrates and have simulcast available on this stream ?

davidzhao commented 2 years ago

yeah it should be possible. the CLI will just need a few param changes to make it accept multiple streams. any suggestions what would be a good syntax to pass in?

If you are interested in creating a PR for it, I'd take it!

nums commented 2 years ago

Thanks for your feedback.

I'm going to work on a PR, to orient myself, from what I've seen, it would be necessary to add the management of the resolutions at the level of the script /cmd/livekit-cli/join.go. It would be necessary to add a parameter of resolution with the publishSocket function and interprete "resolution" parameter from the cli (a bit like it was done here: /pkg/loadtester/loadtester.go at the PublishVideoTrack level)

We would therefore have the possibility of managing the resolution in this way:

$ livekit-cli join-room --room yourroom --identity bot \
  --publish --resolution high unix:/tmp/myvideo_high.h264.sock \
  --publish --resolution medium unix:/tmp/myvideo_medium.h264.sock \
  --publish --resolution low unix:/tmp/myvideo_low.h264.sock \
  --publish unix:/tmp/myvideo.opus.sock
davidzhao commented 2 years ago

sounds good! feel free to find me in our slack community's #dev channel if you'd like to discuss in real time.

I think --publish should be used to identify unique tracks. It would be great to do something like this instead:

--publish-simulcast 1280x720=h264:///tmp/myvideo_high.sock,640x360=h264:///tmp/myvideo_medium.sock,320x180=h264:///tmp/myvideo_low.sock

here we would pass in multiple parameters of the track separated with comma. it'd be possible to also set track name this way, i.e. name=var

67 adds the ability to use TCP sockets too, and there is a proposed improvement to the syntax, which I've adopted here