livekit-cli icon indicating copy to clipboard operation
livekit-cli copied to clipboard

Simulcast with ffmpeg

Open nums opened this issue 2 years ago • 3 comments

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

nums avatar Jul 20 '22 11:07 nums

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!

davidzhao avatar Jul 22 '22 06:07 davidzhao

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

nums avatar Jul 29 '22 10:07 nums

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

davidzhao avatar Jul 29 '22 16:07 davidzhao