I wrote a Laravel API which allow me to set a watermark on a video previously uploaded with another endpoint.
The endpoint that allow the user to set the watermark accept the image file and the video id as parameter.
The route call this function:
public function setWatermark(Request $request)
{
$request->validate([
'watermark' => 'required|max:1000'
]);
$userId = auth()->user()->id;
// generate a random name for the watermark
$watermarkName = Str::random(10) . '.png';
// this store the watermark image to the user folder
$watermarkPath = $request->file('watermark')->storeAs($userId, $watermarkName, 'public');
// get the video (current size is 1kb) - 10 seconds
$video = Video::where([
'id' => $request->id,
'customer_id' => auth()->user()->id,
])->firstOrFail();
$videoUrl = str_replace('/storage/', '', $video->video_url);
// apply the watermark
\FFMpeg::fromDisk('public')
->open($videoUrl)
->addWatermark(function (WatermarkFactory $watermark) use ($watermarkPath) {
$watermark->fromDisk('public')
->open($watermarkPath)
->right(25)
->bottom(25);
})
->export()
->toDisk('public')
->inFormat(new \FFMpeg\Format\Video\X264)
->save($userId . '/' . 'test.mp4');
return response()->json(['success' => true]);
}
The main issue's that to apply the watermark to a video of 10 seconds I should wait 2 minutes at least.
Is that something incorrect I did in the configuration or in the code?
I wrote a Laravel API which allow me to set a watermark on a video previously uploaded with another endpoint. The endpoint that allow the user to set the watermark accept the image file and the video id as parameter. The route call this function:
This is my current configuration:
The main issue's that to apply the watermark to a video of 10 seconds I should wait 2 minutes at least. Is that something incorrect I did in the configuration or in the code?