0
Not a bug

no thumbnails for video mp4 files

slavikca 10 months ago updated by Vlad R 10 months ago 7

I just installed Filerun via Docker.

Copied few video files to my library and I see no thumbnails.

Photo files has correct thumbnails, but mp4 video files are just white blank icons.

I checked and "Enable FFmpeg support" is checked and when I click "Check version" I'm getting 

> ffmpeg version 4.1.8-0+deb10u1 ...

I even tried to run php script, but it says:

docker exec  filerun php /var/www/html/cron/make_thumbs.php
-------------------- START ----------------------
Image size: 400 x 400
Generating thumbnails for superuser's files:

Processing folder: /user-files
Getting directory listing...: 120 files found

Processing files:
119 /user-files/Lessons/Lesson 001-2/02.mp4.av1.mp4 ............................... ... No thumb needed
118 /user-files/Lessons/Lesson 001-2/03.mp4.av1.mp4 ............................... ... No thumb needed
....
2 /user-files/Lessons/Lesson 163-164/24.mp4 ..................................... ... No thumb needed
1 /user-files/Lessons/Lesson 163-164/25.mp4 ..................................... ... No thumb needed
0 /user-files/Lessons/Lesson 163-164/26.mp4 ..................................... ... No thumb needed

0 files processed.

So, how do I enable thumbnails for video files?

Answer

Answer
Not a bug

It is most probably the permissions of those folders.

See: https://docs.filerun.com/troubleshooting_thumbnails

Make sure the folder the image files are in, are writable by PHP. FileRun needs to cache the generated thumbnails in a hidden folder next to the files. If the folder should be read-only, then configure FileRun with an external location for the thumbnail cache (see $config['path']['thumbnail_cache'] on this page)

Hm, I found, that if I upload the video file via web-interface - then thumbnail generated correctly.

But when I just copied files to /user-files - it doesn't work.

See this example:

http://filerun.slavikf.com/wl/?id=Dbj5rGScQ2tDCpyBvtgjo8khqusmirsi&mode=gallery

- 2 files in the root have thumbnails

- all files in the folder are just blank


I ran:

- metadata_update_file_type.php /user-files/

- metadata_index.php


Nothing helps. Only uploading via web-interface works.

Answer
Not a bug

It is most probably the permissions of those folders.

See: https://docs.filerun.com/troubleshooting_thumbnails

Make sure the folder the image files are in, are writable by PHP. FileRun needs to cache the generated thumbnails in a hidden folder next to the files. If the folder should be read-only, then configure FileRun with an external location for the thumbnail cache (see $config['path']['thumbnail_cache'] on this page)

You probably right about file permissions.

But it appears, that filerun does something incorrect about handling that.

I just created new folder `thumbnail_cache`

chmod 777 thumbnail_cache

mounted it in Docker:

- ./thumbnail_cache:/thumbnail_cache


Added it to config.php:

$config['path']['thumbnail_cache'] = '/thumbnail_cache/';


restarted filerun

I'm seeing same error while generating thumbnails:

[image2 @ 0x55f2c9fe1700] Opening '/thumbnail_cache/user-files/Lessons/Lesson 163-164/01.mp4/extracted.png' for writing
 [file @ 0x55f2ca6a9800] Setting default whitelist 'file,crypto'
 [image2 @ 0x55f2c9fe1700] Could not open file : /thumbnail_cache/user-files/Lessons/Lesson 163-164/01.mp4/extracted.png
 av_interleaved_write_frame(): Input/output error
 Output file #0 (/thumbnail_cache/user-files/Lessons/Lesson 163-164/01.mp4/extracted.png):
 Conversion failed!
--------------------
Extraction failed

And when I'm looking at the "thumbnail_cache" folder, I see, that some folders creates as "root", and some as user 1000:

ls -l thumbnail_cache/user-files/Lessons/
total 0
drwxr-xr-x 1 root root 16 Feb 12 00:39 10.mp4
drwxr-xr-x 1 root root 16 Feb 12 00:39 12.mp4.av1.mp4
drwxr-xr-x 1 root root 336 Feb 12 00:37 'Lesson 001-2'
drwxr-xr-x 1 1000 1000 336 Feb 12 00:37 'Lesson 003-4'

I tried to manually force correct ownership:

sudo chown -R 1000:1000 thumbnail_cache

And I see, that thumbs are generated now:

 Output file #0 (/thumbnail_cache/user-files/Lessons/Lesson 163-164/01.mp4/extracted.png):
 30 frames successfully decoded, 0 decoding errors
--------------------
Extraction result type: file
Extracted to: /thumbnail_cache/user-files/Lessons/Lesson 163-164/01.mp4/extracted.png
Extracted file size: 16146 bytes (16 KB)
File is safe for web.
File is smaller than 8 MB.
Checking image resolution.
Image size is 400 x 267
Requested size is 400 x 400
Original image does not need resizing.
Moving extracted to cache.
Displaying cached file: /thumbnail_cache/user-files/Lessons/Lesson 163-164/01.mp4/195710206/400_400_contain[1].png
Cache file size: 16146 bytes
Caching is off.
Keeping the generated cache file.
Removing lock: /thumbnail_cache/user-files/Lessons/Lesson 163-164/01.mp4/195710206/400_400_contain[1].png.lock
Processing time: 0.5732 seconds.

However, when I open the folder - it still blank icons, no thumb for that file

see 01.mp4 here:

http://filerun.slavikf.com/wl/?id=Dbj5rGScQ2tDCpyBvtgjo8khqusmirsi&path=Lesson%20163-164&mode=gallery

I finally got it working.

First, I set

$config['path']['thumbnail_cache'] = '/thumbnail_cache/';

Thumbnails were generated succesfully, but couldn't be loaded by browser because of this server error:

(20023)The given path was above the root path: [client 192.168.240.1:44552] xsendfile: unable to find file: /thumbnail_cache/user-files/Lessons/Lesson 163-164/23.mp4/32147733/400_400_contain[1].png


So, looks like there is some Apache setting, preventing it from server any files outside of /var/www/html.

So, I set this:

$config['path']['thumbnail_cache'] = '/var/www/html/thumbnail_cache/';

And now it works!

Looks like you need to update documentation here:

https://docs.filerun.com/advanced_configuration

And say, that for $config['path']['thumbnail_cache'] = '/path/with/write/permission/';

the path shall be inside /var/www/html

or Apache config needs to be edited to allow "outside" path.

And... it's only actually works for logged-in user.

If I use share (web-link) - thumbnails are not working. 

Here is the share example:

http://filerun.slavikf.com/wl/?id=X2Fo2Ma4p8A3n6aaCF9vpc4Gd7DtdpgA

When you open it - there are 2 of 404 errors for link like this:

  1. Request URL: http://filerun.slavikf.com/wl/?id=X2Fo2Ma4p8A3n6aaCF9vpc4Gd7DtdpgA&path=10.mp4&mode=grid&thumbnail=1

Same error in the server log:

[:error] [pid 1387] (20023)The given path was above the root path: [client 172.19.0.1:52530] xsendfile: unable to find file: /var/www/html/thumbnail_cache/user-files/Lessons2/10.mp4/29164353/400_400_contain[1].png

This file actually exists. Not sure, why Apache can't serve it.

sudo docker exec filerun ls -l /var/www/html/thumbnail_cache/user-files/Lessons2/10.mp4/29164353/400_400_contain[1].png
-rwxrwxrwx 1 user user 36286 Feb 12 18:06 /var/www/html/thumbnail_cache/user-files/Lessons2/10.mp4/29164353/400_400_contain[1].png

When I look at files as authenticated user, the requests for thumbnails looks like this:

http://filerun.slavikf.com/t.php?p=%2FROOT%2FHOME%2FLessons2%2F10%2Emp4&s=29164353&t=1644680760&noIcon=true

And works fine.

FileRun Docker comes configured with Apache "mod_xsendfile" enabled in FileRun control panel as a download accelerator (under the "Files" section).

The root folder from where the accelerator is allowed to send files is set to "/user-files" via the config file "/etc/apache2/conf-available/filerun.conf".

Something like this should work better:

$config['path']['thumbnail_cache'] = '/user-files/.filerun.thumbscache';

The folder ".filerun.thumbscache" will not be visible or accessible not even if it is set inside a FileRun user home folder.