DisboxApp / web

Use Discord as a file storage service.
https://disboxapp.github.io/web/
GNU Affero General Public License v3.0
458 stars 86 forks source link

Adding media player #27

Open Yumasko opened 1 year ago

Yumasko commented 1 year ago

I use disbox to store my movies, and some photos. (Just as a backup). It would be nice to be able to play media files in the browser instead of having to download it.

Shieldowskyy commented 1 year ago

I think this is not possible because it would require downloading the entire video to your computer before playing. This is even more apparent with MP4 files which store the header at the end of the file.

Yumasko commented 1 year ago

I think this is not possible because it would require downloading the entire video to your computer before playing. This is even more apparent with MP4 files which store the header at the end of the file.

Couldn't you just download the segments of the file as you are watching the file?

regan-prendergast commented 1 year ago

Couldn't you just download the segments of the file as you are watching the file?

I don't think Disbox is really designed for streaming files from the Discord storage, it's more designed for long term static storage. Things that you'd prefer to put away and not need to access on a regular basis.

However, if you really want to stream video from Disbox, you can achieve this with mkv files since they allow you to play individual segments of the video file. The upside is you can start playing the file immediately once the download begins, the downside (among others) is you probably won't be able to skip to different parts of the video since the segments are being downloaded sequentially, it has to start from the beginning. Also it can be a little glitchy/stuttery depending on how fast discord is giving you the parts.

Here is me playing a 4k mkv file as it's downloading, by playing the .crswap file in mpv.net

image

Again, I wouldn't recommend Disbox for this kind of thing.

DisboxApp commented 1 year ago

Hey guys! I agree that while you could download the file, it's more convenient to have that feature built in. It's also true that with some file formats this could be possible (as shown by regan).

I recently stumbled into the expermintal (Chrome 94+) MediaStreamTrackGenerator that should act as a MediaStreamTrack that can be written to using a WritableStream, which is what Disbox's downloadFile method accepts. This MediaStreamTrack can then be provided to react-player as the video source.

This sounds like theoretically it shuold be pretty straightforward to implemenet and a cool feature to add, but I'm getting some weird errors I can't find anywhere online:

Uncaught (in promise) TypeError: Failed to execute 'write' on 'UnderlyingSinkBase': Null video frame.

If anyone wants to locally clone the project and mess around with to see if they can get it to work that'd be great :)

Scopen86 commented 6 months ago

Hey! @DisboxApp I have just come across a similar project that support playing videos albeit sometimes buggy but it's possible, you may want to check it out! https://github.com/Zeptosec/Thermastore