Video thumbnails not generated or showing

Nextcloud version (eg, 29.0.5): 27.1.3
Operating system and version (eg, Ubuntu 29.04): Ubuntu 20.04.4 LTS
Apache or nginx version (eg, Apache 2.4.25): nginx/1.18.0
PHP version (eg, 8.3): 8.1

The issue you are facing:
I have mp4 files that are missing thumbnails.

ffmpeg is installed. It’s path is included in the PATH environment variable and the path is one of the paths used by NextCloud when looking for ffmpeg (can’t seem to find the GitHub link to that code anymore). ffmpeg has execute permissions for User, Group, and Other.

imagemagick and ghostscript are both installed and up to date.

My config includes;

'enable_previews' => true,
  'enabledPreviewProviders' =>
  array (
    0 => 'OC\\Preview\\TXT',
    1 => 'OC\\Preview\\MarkDown',
    2 => 'OC\\Preview\\OpenDocument',
    3 => 'OC\\Preview\\PDF',
    4 => 'OC\\Preview\\MSOffice2003',
    5 => 'OC\\Preview\\MSOfficeDoc',
    6 => 'OC\\Preview\\Image',
    7 => 'OC\\Preview\\Photoshop',
    8 => 'OC\\Preview\\TIFF',
    9 => 'OC\\Preview\\SVG',
   10 => 'OC\\Preview\\Font',
   11 => 'OC\\Preview\\MP3',
   12 => 'OC\\Preview\\Movie',
   13 => 'OC\\Preview\\MKV',
   14 => 'OC\\Preview\\MP4',
   15 => 'OC\\Preview\\AVI',
  ),

Running occ preview:generate-all, I can see that it finds the video files and I get “Generating previews for…” and no errors. Nothing is output to the log.

I’ve read through every post I can find on the issue, and many are either related to ffmpeg or config not being correct. It seems many of those posting never find a solution. Is there anything else I can try / anything else I can do to troubleshoot short of stepping through the code?

First of all you should check your Nextcloud log file for any related errors. As I activated the video preview, some required libraries were missing on the server which ffmpeg requires to generate the files.

":"Movie preview generation failed Output: /usr/bin/ffmpeg: error while loading shared libraries: libzimg.so.2: cannot open shared object file: No such file or directory"

Next I tested if the preview generation is worked without any errors by execution the following command on the console. (The movie file has been moved to a test folder):

/usr/bin/ffmpeg -y -ss 3 -i /tmp/PREVIEW/test.mp4 -f mjpeg -vframes 1 /tmp/PREVIEW/test.jpg; echo $?

After this has worked without any issues and the generated jpg-file showed what I expected, I restarted my web server and php to make sure the image isn’t fetched from the cache.

It’s path is included in the PATH environment variable

BTW, I found out that a new configuration parameter has been introduced with NC 28.x (?) which allows to set the ffmpeg path:

'preview_ffmpeg_path' => '/usr/bin/ffmpeg',
1 Like

Thanks for a response with definite actions I could take.

Nothing is written to the log during preview generation.

Executing ffmpeg directly results in a valid jpg from an mp4 file that I copied from NextCloud, so we know ffmpeg and it’s dependencies are there.

I’ve tried restarting php and nginx, but it’s made no difference.

There ain’t no preview providers "MKV", "MP4" and/or "AVI". Only "Movie".
Remove those fantasy providers from the array and then it should normaly work.

Fingers crossed!
:hand_with_index_finger_and_thumb_crossed:


Much and good luck,
ernolf

1 Like

I had the same issue since a long time. Not any preview besides jpeg was generated although enabledPreviewProviders was set for many types. The reason was: 2 backslashes in the config lines :roll_eyes:
Once I removed the second backslash from the config lines, preview generation for mp4 files started like expected when executed occ preview:generate-all.

On an iOS device, video files were not appearing in the media tab, but the following solution worked for me. Thank you!
Video files do not appear in the media tab · Issue #3262 · nextcloud/ios

As of current date, I have found that some of your preview arrays are invalid so I have inserted the following section into my config.php file.

'enabledPreviewProviders' =>
  array (
    0 => 'OC\\Preview\\BMP',
    1 => 'OC\\Preview\\GIF',
    2 => 'OC\\Preview\\JPEG',
    3 => 'OC\\Preview\\Krita',
    4 => 'OC\\Preview\\MarkDown',
    5 => 'OC\\Preview\\MP3',
    6 => 'OC\\Preview\\OpenDocument',
    7 => 'OC\\Preview\\PNG',
    8 => 'OC\\Preview\\TXT',
    9 => 'OC\\Preview\\XBitmap',
    10 => 'OC\\Preview\\Movie',
  ),

In addition to this, you also need to have ffmpeg installed wherever nextcloud is running. ffmpeg isn’t preinstalled in the nextcloud container image so to install it you have to type the following commands.

docker exec -it -u root nextcloud bash

This will give you root access to your container where you could then do the following

apt update && apt install ffmpeg -y

I hope this helped someone as It worked for me.