Laravel 框架中如何使用 Storage 存储 PHP-FFmpeg 生成的缩略图
业务需求:
用户上传MP4
文件,后端提取缩略图、并使用storage
存储(要考虑兼容oss、等非本地存储方式)。
使用到的扩展包
1、php-ffmpeg/php-ffmpeg
2、intervention/image
常规操作(缺少使用storage来存储缩略图)
$ffmpeg = FFMpeg\FFMpeg::create([
'ffmpeg.binaries' => config('ffmpeg.ffmpeg.binaries'),
'ffprobe.binaries' => config('ffmpeg.ffprobe.binaries'),
]);
$video = $ffmpeg->open($request->file('files'));
$video->frame(FFMpeg\Coordinate\TimeCode::fromSeconds(15))->save(public_path('frame.jpg')); // 这边如何跟Storage配合使用
可以先存到项目的 storage/tmp 目录,然后在上传到对应的 Storage driver 里