LibrePhotos / librephotos

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

Nextcloud Scan does not handle videos #278

Open derneuere opened 3 years ago

derneuere commented 3 years ago

Currently, the scan for Nextcloud only handles images. It should also include video files.

sethgillett commented 2 years ago

This should be a pretty trivial fix right? All we have to do is change a few lines of code in directory_watcher.py. Currently the function isValidNCMedia reads:

def isValidNCMedia(file_obj):
    file_attr = file_obj.attributes
    filetype = file_attr.get("{DAV:}getcontenttype", "")
    try:
        return (
            "jpeg" in filetype
            or "png" in filetype
            or "bmp" in filetype
            or "gif" in filetype
            or "heic" in filetype
            or "heif" in filetype
        )
    except Exception:
        util.logger.exception("An image throwed an exception")
        return False

This could be changed to something like:

def isValidNCMedia(file_obj):
        ...
        return (
            "jpeg" in filetype
            or "png" in filetype
            or "bmp" in filetype
            or "gif" in filetype
            or "heic" in filetype
            or "heif" in filetype
            or "mov" in filetype
            or "mp4" in filetype
        )
        ...

Am I missing something here?

derneuere commented 2 years ago

Yes, that would be an option, but there are more video formats. We solved that with magic, a python package here:

https://github.com/LibrePhotos/librephotos/blob/47f30b6ca2b35fbe91aa019986d253eadff2a8f9/api/directory_watcher.py#L24-L27

If you want that functionality now, you could open a pull request with a temporary solution by adding more file extensions.

I would then still be keeping this issue open. I think there must be some kind of API to get some information if it is a video in general, but I hadn't time to investigate it yet.

munsuri commented 2 years ago

Hi. I actually added some additional file types to directory_watcher.py as a temporary solution and it worked. The videos also play while hovering over the thumbnail with the mouse but when clicking on them for full playback, audio is played but no video image is shown: Screenshot 2022-03-08 001230 Those thumbnail_big 404 error in the console appear when clicking on the videos for full playback.

Note 1: It might be related to https://github.com/LibrePhotos/librephotos/issues/379 but I'm not completely sure about it... Note 2: And yes, as test I did enable "Always transcode videos" and it worked but makes the whole thing slow, specially with long videos, so not sure whether that "experimental"? solution is meant as permanent...

Any idea/hint where to look next? Could this be a frontend issue? Thanks!

derneuere commented 2 years ago

The issue is that you have x265 encoded videos. No browser handles this natively. On demand transcoding is still experimental as I haven't had the time to implement it properly yet.

munsuri commented 2 years ago

Thanks for your quick reply! I will take a look at the experimental transcoding option because it seems to not work in Apple world, at least for Mac and iPad, and report back if I find something.

meichthys commented 2 years ago

Just in case anyone else is looking for a work-around, it might be worth trying to mount the nextcloud photos directory directly to librephotos as mentioned in #55. This has a few benefits:

I haven't noticed any drawbacks from doing this yet, but perhaps there will be a performance hit (haven't noticed it yet).

munsuri commented 2 years ago

That's a very interesting workaround, thanks for pointing it out as I had totally missed it in the issues search! Will most surely give it a try.

meichthys commented 2 years ago

@sethgillett would you mind submitting a pull request for the temporary fix?

varet80 commented 1 year ago

Yes, that would be an option, but there are more video formats. We solved that with magic, a python package here:

https://github.com/LibrePhotos/librephotos/blob/47f30b6ca2b35fbe91aa019986d253eadff2a8f9/api/directory_watcher.py#L24-L27

If you want that functionality now, you could open a pull request with a temporary solution by adding more file extensions.

I would then still be keeping this issue open. I think there must be some kind of API to get some information if it is a video in general, but I hadn't time to investigate it yet.

should we add the option of more file extensions, in case somebody scans a folder with other files (outside videos and photos) and then use Magic only for know video extensions? or is not making sense to do it that way?