LibrePhotos / librephotos

A self-hosted open source photo management service. This is the repository of the backend.
MIT License
6.67k stars 291 forks source link

Add transcoding for video #365

Open derneuere opened 2 years ago

derneuere commented 2 years ago

As a user, I want to view video files that are not native to the browser.

I looked for that in the implementation in stash. Sadly it is implemented in Go, but the general structure will be useful for our implementation:

derneuere commented 2 years ago

Here is a short article about that: https://cjwebb.com/python-docker-ffmpeg-h264-mp4/

Here is an example on how to do something similiar in python and flask: https://gist.github.com/anthonyeden/f3b3bdf6f62badd8f87bb574283f488a

We should then use django streaming response: https://stackoverflow.com/questions/38514919/django-stream-request-from-external-site-as-received

derneuere commented 2 years ago

An experimental option was added. StreamingHTTPResponse does not seem to stop once you close the light box, but it does when the window is closed. I have to investigate what possible fixes are.

We can use the same endpoint, but add a bit of information like "?s=109&r=1080" or something like that. This will obviously only be relevant when transcoding.

We also have to write a custom ReactPlayer to override the duration, as the video file from ffmpeg does not know while transcoding how long it will be. This should be added to the photo model as an attribute.

derneuere commented 2 years ago

Now the process closes reliably.

derneuere commented 2 years ago

flaurafauna noted that it currently uses all available resources when transcoding. This should be more limited to be a bit faster than real-time, as more transcoding power is not needed for viewing.

Also, sometimes the pause / scrub bars missing. Not sure if that's also related to transcoding.