Open zhyu opened 1 year ago
This is probably the same issue as #4044. Stash does not properly support TIF/TIFF images - only png
, gif
, jpeg
, webp
and avif
. Any other formats are sent through to ffmpeg
, and are incorrectly detected as Image Clips. ffmpeg
also appears to not be able to generate thumbnails properly for TIFF images.
The image extension list is a bit deceptive - adding an extension there only means that Stash will scan it (instead of ignoring it) and try to parse the format as an image. This image parsing ignores the file extension entirely, and it is only able to recognize images that in the formats I listed above.
A bit of a rework is needed, which should fix both this issue and #4044.
I see. So I locally patched stash
like https://github.com/stashapp/stash/pull/3913, now TIF/TIFF images are recognized as images. The thumbnail generation is still not working as you mentioned.
The error log suggests ffmpeg
reads from stdin to generate thumbnails (-i -
) and I can reproduce the error locally with cat image.tif | ffmpeg #args from the error log
.
However, the error is gone if I update the command to read from the local file (-i /path/to/image.tif
) and I can open the generated thumbnail file without issues 🤔
Interestingly, if I move -i -
to the end of the arg list, the error is gone as well. However, the image quality of the generated thumbnail is much worse than the thumbnail generated with -i /path/to/image.tif
.
Maybe the command to generate thumbnails needs to be tuned.
I patched the ffmpegImageThumbnail function locally to fallback to read from the image file if error happens when reading from stdin, now thumbnails for TIF files can be generated as expected.
Yeah the patch in #3913 is a bit of a hack imo. The reason why we have ffmpeg
read from stdin is because we need to be able to generate thumbnails from images which are inside zip files, which ffmpeg can't read from directly. The file is read by stash (either from inside a zip file or directly from the filesystem) and sent to ffmpeg's stdin.
I found this issue on ffmpeg's bugtracker: https://trac.ffmpeg.org/ticket/5561 ffmpeg doesn't support reading tiff images from stdin.
I think the solution might be to use vips
for everything, and only fallback to using built-in image detection or ffmpeg
if it is not present. libvips
supports TIFF natively and JPEG XL if libjxl
is present, so it should solve both these issues.
We can easily log a warning message if a format that only vips supports is used while vips is not installed.
Just my two cents, without remembering too well, I had problems with vips when implementing the image clips, so there may be some formats not working with it. In case this gets into a PR, make sure all image formats are tested, including the less common avif, gif and webp.
For the time being, in order to view tiff, here is my workaround
-- Insert rows into image_files table for video files with video_codec 'tiff' INSERT INTO image_files (file_id, format, width, height) SELECT v.file_id, v.video_codec, v.width, v.height FROM video_files v LEFT JOIN image_files i ON v.file_id = i.file_id AND v.video_codec = 'tiff' WHERE i.file_id IS NULL AND v.file_id NOT IN (SELECT file_id FROM image_files);
-- Retrieve the inserted rows SELECT * FROM image_files WHERE file_id IN (SELECT file_id FROM video_files WHERE video_codec = 'tiff');
You need to do this every time your add new tiff files
It seems TIF images cannot be processed correctly.
Auto-gallery creation is not working after scanning a folder containing TIF images only. Thumbnail generation is not working and TIF images cannot be displayed as well.
A snippet of error logs: