I'm trying to generate thumbnails from video uploads and upload them directly to S3 without re-opening the file after it's uploaded.
I'm not sure how to really do this since php-ffmpeg documentation isn't good. Here's the code I'm trying but not sure what's wrong. I'm trying to upload using $disk->put since I'm not sure how to implement S3 into this.
$thumbnailPath = 'bucket.s3.eu-west-1.amazonaws.com/thumbnails/' . $id . '.' . $fileExtension;
$ffmpeg = FFMpeg::create();
$video = $ffmpeg->open($file);
$frame = $video->frame(TimeCode::fromSeconds(5));
$img = $frame->save($thumbnailPath);
$disk->put($thumbnailPath, fopen($img, 'r+'));
I wrote the above code based off of how I'm generating thumbnails for normal images (which works perfectly):
$img = Image::make($file)->resize(150, null, function ($constraint) {
$constraint->aspectRatio();
});
$disk->put($thumbnailPath, $img->stream());