Estado inicial: frontend React + backend Laravel
This commit is contained in:
27
plataforma-tutorias/app/services/videoService.php
Normal file
27
plataforma-tutorias/app/services/videoService.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use FFMpeg\FFMpeg;
|
||||
use FFMpeg\Coordinate\TimeCode;
|
||||
|
||||
class VideoService
|
||||
{
|
||||
public function generateThumbnail(string $videoPath): string
|
||||
{
|
||||
$ffmpeg = FFMpeg::create([
|
||||
'ffmpeg.binaries' => 'C:/Users/Livetech/AppData/Local/Microsoft/WinGet/Packages/Gyan.FFmpeg_Microsoft.Winget.Source_8wekyb3d8bbwe/ffmpeg-8.1-full_build/bin/ffmpeg.exe',
|
||||
'ffprobe.binaries' => 'C:/Users/Livetech/AppData/Local/Microsoft/WinGet/Packages/Gyan.FFmpeg_Microsoft.Winget.Source_8wekyb3d8bbwe/ffmpeg-8.1-full_build/bin/ffprobe.exe',
|
||||
]);
|
||||
|
||||
$video = $ffmpeg->open(storage_path('app/public/' . $videoPath));
|
||||
|
||||
$frame = $video->frame(TimeCode::fromSeconds(5));
|
||||
$thumbnailPath = 'thumbnails/' . uniqid() . '.jpg';
|
||||
$fullPath = storage_path('app/public/' . $thumbnailPath);
|
||||
dd($thumbnailPath);
|
||||
$frame->save($fullPath);
|
||||
|
||||
return $fullPath;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user