Chocobozzz / PeerTube

ActivityPub-federated video streaming platform using P2P directly in your web browser
https://joinpeertube.org/
GNU Affero General Public License v3.0
12.75k stars 1.46k forks source link

Live stream from uploaded video? #6136

Open sneakers-the-rat opened 6 months ago

sneakers-the-rat commented 6 months ago

Describe the problem to be solved

Hello! I've searched and can't find a matching issue, sorry if this is a duplicate.

I'd like to be able to upload a movie, schedule a start time for it, and stream it via p2p to a group of friends for a remote movie watching event (monsterdon on the fediverse). Peertube seems like the right fit, but it doesn't seem like it's possible to start a stream from an already-uploaded video, and that instead I would have to stream that video from some other computer via OBS to PeerTube and then to the rest of the people watching.

Live seems like the right fit for this, since there would be a large-ish number of people who specifically want to watch the same movie at the same time, and stay synchronized in time across viewers (rather than everyone starting the movie at the same time, people should be able to come and go, join and close the stream) while being able to take advantage of p2p streaming since the host server is not very beefy.

This would also allow us to pre-transcode the movie into lower resolutions for lower bandwidth people, rather than needing to live-transcode it, which our server is not powerful enough to do.

This is a more general need beyond just monsterdon, as I am frequently with groups of people who will eg. use discord to stream a movie together, because the other options for streaming a movie with remote friends are just not good! peertube could be that good option!

Describe the solution you would like

It would be nice to have an option in the "go live" menu to be able to select from already-uploaded movies and select a start time for the stream. The live would then automatically play that video at that starting time.

It seems like this would be simple enough to do, since instead of needing to read from a stream the server could just read from videos it already has, but in reading the source just now I can't see the best way to implement that. If you can hint me towards how y'all would implement streaming from an uploaded video, i'd be happy to draft and submit a PR <3

Some Starts

that's where i sort of lose where i would add a field to the LiveVideoModel to specify a source video and how peertube actually fetches data from the stream, but if you point me to where that would be, as well as any UI components i could patch in for selecting videos, again I would love to contribute :).

Chocobozzz commented 6 months ago

Hi,

Thanks for the issue. Why streaming the film from OBS or directly ffmpeg is not a suitable solution for you?

sneakers-the-rat commented 6 months ago

tl;dr


We would like to stream videos that might be larger than our home connection upload speed can handle, and ideally take advantage of multiple resolution transcodes for ppl with varying download connection speeds.

Streaming a pre-recorded video would be a great feature to support remote movie watch parties in general, which are currently relatively cumbersome to do - the most accessible way I know of is to share screen in a discord call, but that routinely suffers from upload connection speed problems, quality issues, and so on. So this would be an absolutely lovely feature for "small web" applications, someone running a small instance for a group of friends, etc. That is currently unfilled by other video streaming systems im aware of. This would also be extremely useful for eg. Academic conferences, which increasingly include pre-recorded talks that are streamed at a particular time (same benefits, being able to run them from a smaller instance w/ more efficient p2p buffering, and high quality is a necessity since the videos frequently include small text and other fine details that can be lost in low-quality streams)

Looking at some recent benchmarks from yall ( https://joinpeertube.org/news/stress-test-2023 ) it also looks like we would be able to make much more efficient use of p2p bandwidth using a pre-recorded video, allowing us to stream a higher quality video with less server bandwidth, since the peers can buffer segments from much further ahead. This would also, presumably, allow us to avoid the necessary delay to use p2p from a livestream.

Im not sure which would be the better dev path: add uploaded videos as a source for a Live, or adding the ability to synchronize watch time across users on a normal video, but I suspect the former?

In any case, if yall are interested, if you give me a rough outline of the things that would need to be changed to make this work, I would be more than happy to draft a PR, write tests, etc. If this would be something that works better as a plugin, lmk and ill work on that!

Mike35538 commented 6 months ago

This seems like it could be a useful feature and contribute to users connecting together to watch a video, especially when combined with the chat plugin. That seems beneficial in promoting community participation for the instance. It seems a lot like YouTube Premieres, which is a great feature. I do like how the videos are "pre-transcoded" after being first uploaded, a long time before the live stream actually occurs. So the instance doesn't have to transcode the video during the live stream broadcast. It would be nice to also have the ability to add a playlist of multiple videos that play one after another during the live stream, instead of limiting it to 1 single video and then the broadcast is over.

ajroach42 commented 5 months ago

We would also benefit from this development. At the moment, I use a tool called ffplayout to manage my livestream, but it's a messy half measure and for all the reasons mentioned here it would be really great to be able to schedule a live stream of content currently on the server.

I recognize that this would be a big digression from how peertube currently operates, but it would make several aspects of running our operation significantly easier.

emansom commented 3 months ago

YouTube has similar functionality to this called premieres.

It shows a countdown video and then "streams" the already uploaded and processed video.

The player shows up as a livestream player with no ability to fast forward.

sneakers-the-rat commented 3 months ago

offering again to draft a PR if the devs point me to some starting points on the implementation they would accept! It doesn't seem like it should be that hard, just swapping out one input source for another, and it would be extremely useful for groups who want to use peertube for events, which is currently very hard to do!

stevespaw commented 3 months ago

I also would love to see this. But instead of a single video, it should play a playlist, that would be the most flexible. This would be a very big feature! "Playlist as Live"