Reputation: 1666
I want to be able to change the frame rate of a video from 0.05fps to 3fps.
I receive the video as an Illuminate\Http\UploadedFile
element, with mp4 format, how do I speed up its frame rate before sending it via email?
The video is 25 minutes long, it should become 25 seconds long after changing the frame rate.
Is there a way to change the fps without saving the element as a File?
I was planning to use the ffmpeg repository here but it requires me to save both the initial file, and the second file after changing the fps.
This is my code:
<?php
namespace Server\Mail;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Http\UploadedFile;
class TimeLapse extends Mailable
{
use Queueable, SerializesModels;
public UploadedFile $video;
public bool $is_timelapsed;
public string $format;
/**
* Create a new message instance.
*/
public function __construct(
UploadedFile $video,
bool $is_timelapsed,
string $format
){
$this->video = $video;
$this->is_timelapsed = $is_timelapsed;
$this->format = $format;
}
private function timelapse(){
// here I want to change $video element's fps from 0.05 to 3
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
if ( !$is_timelapsed ) { timelapse(); }
$this->subject('message')
->text('emails.timelapse');
$this->attach($this->video, [
'as' => 'sample'.$format,
'mime' => 'video/'.$format,
]);
return $this;
}
}
Upvotes: 0
Views: 189