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.77k stars 1.46k forks source link

DVR support #6461

Open fabiopicchi opened 1 week ago

fabiopicchi commented 1 week ago

Describe the problem to be solved

The client stack we use supports seeking HLS live streams (hlsjs + videojs). However, Peertube's client explicitly disables time controls in the GUI when broadcasting live. https://github.com/Chocobozzz/PeerTube/blob/0870a3fe51d88b69ad6bc7465903207f85d2e15f/client/src/assets/player/shared/peertube/peertube-plugin.ts#L522

Another issue is that the amount of ts files kept (necessary to control the buffer size) is not currently parametrizable and is a constant set here. https://github.com/Chocobozzz/PeerTube/blob/0870a3fe51d88b69ad6bc7465903207f85d2e15f/server/core/initializers/constants.ts#L1034

I tried modifying these two files to see if I could enable rewinding the live stream all the way to the beginning and I was able to achieve some success, but the behavior is still a bit clunky.

  1. I turned on the liveui flag here: https://github.com/Chocobozzz/PeerTube/blob/0870a3fe51d88b69ad6bc7465903207f85d2e15f/client/src/assets/player/peertube-player.ts#L416

  2. I disabled the smooth scrolling (since time calculation doesn't support live streams) here: https://github.com/Chocobozzz/PeerTube/blob/0870a3fe51d88b69ad6bc7465903207f85d2e15f/client/src/assets/player/shared/peertube/peertube-plugin.ts#L224

  3. I forced p2p to false here: https://github.com/Chocobozzz/PeerTube/blob/91302ea12a4f9776d30f15b72f0217f71a6d6a9d/client/src/assets/player/shared/player-options-builder/hls-options-builder.ts#L134

I was able to get a working UI but, for some reason, the seekbar isn't displayed as the live begins. I have to refresh the page for it to show itself. Also, the time being displayed in the control bar isn't nice, it would be cool if it displayed a negative time as in the seekbar and the "-:-:-" for the upper time limit isn't the best as well. I am opening this ticket to ask how to properly implement this feature. I would gladly contribute with its development if I can get some instructions.

Describe the solution you would like

I want to be able to seek a live stream, moving back and forth between what was already played and the live incoming bits of video.

fabiopicchi commented 1 week ago

@Chocobozzz could you help me push forward this feature even if in a hacky way. The behaviour mostly works, but I can't understand why the seekbar isn't displayed as soon as the live starts. You have to refresh the page for it to show...

Do you know what might be toggling it off at the beginning?

fabiopicchi commented 1 week ago

Not sure if it helps, but here are my changes: https://github.com/fabiopicchi/PeerTube/commit/51defabecb414d21da18dc12aff667551f94aee8