nextcloud / previewgenerator

Nextcloud app to do preview generation in the background.
https://apps.nextcloud.com/apps/previewgenerator
GNU Affero General Public License v3.0
455 stars 57 forks source link

Need support for Apple HEIF and HEIC for Nextcloud #432

Closed myownway888 closed 5 months ago

myownway888 commented 10 months ago

It takes a lot of time for conversion to happen and also drains battery so please add the Apple High Efficiency format to make our and phone's lives easy :)

th0rgall commented 10 months ago

Do you mean that you don't want previews to be generated for .HEIC/.HEIF media files? Perhaps this is configurable, if not, this is probably a request for such a setting to be added?

st3iny commented 10 months ago

Or is this about generating previews for HEIC files? Because this is already implemented via Imaginary.

myownway888 commented 10 months ago

It’s about generating the previews, I am not very good at coding and stuff by the way. I was searching online for this and found that there is no direct support (install an app or plugin and good to go kinda stuff). If you guys can help me through I would really appreciate that.

myownway888 commented 10 months ago

Do you mean that you don't want previews to be generated for .HEIC/.HEIF media files? Perhaps this is configurable, if not, this is probably a request for such a setting to be added?

I want HEIC/.HEIF preview to be automatically generated without opening the configuration for people like me with less coding knowledge. This is a request to add such settings 🙏.

myownway888 commented 10 months ago

The video or image won’t open up until it’s downloaded on to the device and also there are no thumbnails. Just wanted to make it clear.

th0rgall commented 10 months ago

I want HEIC/.HEIF preview to be automatically generated without opening the configuration for people like me with less coding knowledge.

As @st3iny pointed out above, this is already the default behavior, at least when your Nextcloud setup has Imaginary installed. When you open a .HEIC file via Nextcloud files/photos, it will generate a non-HEIC preview and thumbnails as required for that file.

You created this issue in the repository of the official Nextcloud app "Preview Generator". In my setup, this app was not enabled by default. Without this app, previews also get generated, but the generation happens on-demand: when you view or open a media file. The purpose of this app is to schedule this generation process all at once or at regular intervals, so it can be done ahead of the opening and viewing of media files.

The video or image won’t open up until it’s downloaded on to the device and also there are no thumbnails.

Depending on the configuration and hardware of your Nextcloud server, the on-demand generation process might be (very) slow. What if you keep you window still on some empty thumbnails for several minutes, without scrolling? Do thumbnails still not appear?

It would be helpful if you specify in more detail how you are using Nextcloud:

Perhaps your setup doesn't have Imaginary or an alternative enabled, and that's why you're not getting previews.

bcutter commented 7 months ago

I want to step in and add me to the requirements list. Currently with v27.1.7.2 previews are not shown for untouched HEICs at all - no matter where (web, iOS app etc.). Not even when opening a file, which is a different behavior to the past, where the preview was shown at least once a file was opened (iOS app for example).

HEIC previews not generated at all:

So now I read previews for HEICs should already work? Where to check the configuration for that? What to I probably need to install on my bare metal NC server?

As I removed server side encryption (not E2EE) yesterday I finally saw the preview-generator cron job doing its job again and now I want to unlock the full potential - including HEICs please.

th0rgall commented 6 months ago

Hey @bcutter, as you can read in the posts above, you need to install Imaginary. My understanding is that the preview generator app integrates with Imaginary to generate previews for .HEIC files, once Imaginary is installed.

Imaginary comes as an optional feature with Nextcloud AIO, but if you're running a bare metal setup, you will probably have to install and configure it yourself. Check this blog post which seems to cover your situation: https://okxo.de/speed-up-nextcloud-preview-generation-with-imaginary

bcutter commented 6 months ago

Really interesting article, even I don't like he's framing the preview generator app as "old" - it is working, maintained and supported, isn't it?

Anyway, I took a deeper look at all the stuff needed. And wow, that seems to add a lot of complexity to the preview chain compared the (originally install, configure once and forget about it) preview_generator app looking at https://github.com/h2non/imaginary?tab=readme-ov-file#prerequisites and https://github.com/h2non/imaginary?tab=readme-ov-file#installation. I don't use Docker so I was looking at https://github.com/h2non/imaginary?tab=readme-ov-file#libvips as probably most straight forward way to use on a Raspberry Pi OS (Debian based). Unfortunately running that install script gives

Could not find libvips using a PKG_CONFIG_PATH of ':/usr/local/lib/pkgconfig:/usr/lib/pkgconfig'
Detected Debian Linux 'buster'
Sorry, I don't yet know how to install libvips on Debian-based buster

Even a sudo apt install libvips before (installed libvips42) was working the install script still gives the same result. I was thinking about building libvips from source according to https://www.libvips.org/install.html, but that makes a HELL of needed other stuff including a dev/build environment - and at the end it maybe won't run too.

So for HEIC previews this is my specific requirement situation:

  1. NC preview generation: imaginary REPLACES preview generator app (according to https://okxo.de/speed-up-nextcloud-preview-generation-with-imaginary/)
  2. Imaginary needs libvips (or several other container platforms)
  3. Libvips can not be installed from apt, for building from source several other stuff is needed

Even I will update the OS in the next months (Buster ends LTS in 06/2024) and step 3 would work then with Bullseye, according to the install script https://raw.githubusercontent.com/h2non/bimg/master/preinstall.sh latest Bookworm is not supported (yet). Ah it's a mess. So, ahm... sorry, I think that's all in all a bit too much for "just" having HEIC previews (again). And come on, for an average Nextcloud part-time admin that's way too complicated. It should really be implemented in an app somehow. Install + use out of the box.


My understanding is that the preview generator app integrates with Imaginary

No it doesn't. Imaginary replaces preview generator, see 1. above. It just abuses preview generator app once for generating previews for existing images:

Nextcloud does not use the Preview Generator to generate the previews, but Imaginary. You can deactivate or delete the preview generator after the build


So, back to business not wasting more admin hours: what's needed to have HEIC preview support in preview generator app?

bcutter commented 6 months ago

Edit: initial HEIC preview generation could be enabled following https://help.nextcloud.com/t/solved-image-previews-only-working-for-heic-photos/164302/8. According to https://github.com/nextcloud/server/pull/28079 it has been disabled by default because of https://hackerone.com/reports/1261413. Manually re-enabling it made HEIC previews to work at all - for live preview generation, which creates quite some load on the server.

Now curious to see if preview generator app can/will render HEIC files too as it has been enabled in config.php.

st3iny commented 5 months ago

All steps required to enable preview generation for HEIC/HEIF are documented here: https://docs.nextcloud.com/server/stable/admin_manual/installation/server_tuning.html#previews Please note the big orange warning box about extra steps that are required to enable HEIC previews.

I'll close the issue as this is not related to the previewgenerator app.

Compiling Imaginary from source or using it directly is discouraged. We provide an up-to-date docker image at docker.io/nextcloud/aio-imaginary:latest. Unfortunately, the official project and docker image seem unmaintained at the moment.

bcutter commented 5 months ago

Initial support already described in my previous post. Open questions (as I still doubt preview generation with this project works for HEIC):

Is there a way to synthetically test if preview generator app actually creates HEIC image previews now? Therefore: is there a need to re-generate previews for all existing images now?

st3iny commented 5 months ago

You can upload a new photo, run pre-generate and check if there is a preview in your browser.

st3iny commented 5 months ago

Regarding the second question: I fear you have to run generate-all again. Old files won't be picked up by pre-generate until they are rewritten. You could narrow it down by providing paths to generate-all.

bcutter commented 5 months ago

You can upload a new photo, run pre-generate and check if there is a preview in your browser.

Don't know how to do that silently (because every client no matter if iOS or Windows) triggers live preview generation on upload. Probably I'd need to upload it to the server in the backend, do a files re-scan, run pregenerate.