Lychee 荔枝相册报错 视频没有缩略图 Extractor::extract -- 147 -- FFmpeg and Exiftool not being available; Extraction of metadata limited to mime type and file size

这个问题的表现一般为 Lychee 无法播放视频,或视频没有缩略图。应该还会伴随其他两条报错:

2022-03-27 19:25:29 -- error   -- App\Actions\Photo\Strategies\AddStandaloneStrategy::do -- 88 -- Failed to generate size variants, error was Media file is reported to be a video, but aperture (aka duration) has not been extracted
2022-03-27 19:25:28 -- error   -- App\Image\SizeVariantDefaultFactory::extractReferenceImage -- 60 -- Media file is reported to be a video, but aperture (aka duration) has not been extracted
2022-03-27 19:25:28 -- notice  -- App\Metadata\Extractor::extract -- 147 -- FFmpeg and Exiftool not being available; Extraction of metadata limited to mime type and file size.

前两条是因为第三条的错误: FFmpeg 和 Exiftool 不可用导致的,因此我们来集中解决第三条即可。

 

1. 问题定位

首先确保你确实安装了 FFmpeg,可运行命令来检查:

ffmpeg -version

若有显示版本号等信息,说明安装正常。

其次检查 Lychee 网页版是否能正确读取视频的信息。任意点击一个视频,再点击右上角的 i 图标,查看是否能显示视频分辨率、帧率等信息。

如果分辨率显示为 null、帧率显示为 0,则进一步检查诊断信息,其中 has_ffmpeg 是否为 0,若全中,基本确认,原因为 Lychee 找不到 ffprobe 执行文件。

 

2. 问题修复

 

cd /usr/local/www/lychee # 请确保进入到你的项目路径
nano vendor/lychee-org/php-exif/lib/PHPExif/Adapter/FFprobe.php
# 如果没安装 nano,可使用 vi 编辑器
# 修改以下内容
protected $toolPath = '/usr/local/bin/ffprobe'; # 引号内替换为你自己的路径,如果不知道,可以使用 which ffprobe 来搜寻 

 

这一步我们把 ffprobe 执行文件的绝对路径告诉了 Lychee,理论上应该已经能够解决问题,重启 php-fpm、nginx、刷新网页一气呵成,然而重启后发现问题依旧,这是为何? 

Lychee 的开发者之一在一个 issue 中回答:

setting has_ffmpeg to 1 is sticky (it won't get reset; no need to re-check). It's only when it's set to its default value of 2 that Lychee checks if ffmpeg is available and resets it to either 0 or 1 based on that check.

即,Lychee 并不会自动检测 ffmpeg 的状态,如果之前 ffmpeg 是有问题的,你修复了以后,has_ffmpeg 不会自动变成 1,你需要手动来调整

因此我们还需要在 Lychee 设置、More 中,修改 has_ffmpeg 的值为 1,然后重启 php-fpm、nginx、刷新网页,即可解决。

posted @ 2022-03-28 16:04  大白0030  阅读(428)  评论(0编辑  收藏  举报