I am using Laravel 4.2
.
I am working on a project of uploading video. The uploaded video should be played in most devices that I am using php-ffmpeg
package from the git-hub
.
The requirement is the transcoding should be done in background. I am using WAMP 2.5
.
What am I doing is, after upload I am firing an asynchronous ajax request
that transcode the video and after successful completion it should insert a record into database containing video name, path etc.
The problem is if I upload a large size video, then I am facing error Maximum execution time of 120 seconds exceeded
.
I know the possible solution is setting max_timelimit
in php.ini
but I don't think it is a feasible solution because if there will be larger video, the same error will occurred again.
Is there any technique that I can bypass this transcoding process in background?
My code is as below :
try{
$video_id = Input::get('video_id');
$video_path = Input::get('video_path');
$path = '/video/'.date('Y').'/'.date('m');
$path .= '/';
$explode_filename = explode("/",$video_path);
$save_filename = $explode_filename[sizeof($explode_filename)-1];
$ffmpeg = FFMpeg\FFMpeg::create(array('timeout'=>0));
$video = $ffmpeg->open($video_path);
$format = new CustomVideo();
$format->setKiloBitrate(1000)
->setAudioChannels(2)
->setAudioKiloBitrate(256);
$video->save($format, public_path().$path.$save_filename);
//saving video
Video::where('id', '=', $video_id)->update(array('is_transcoded' => 1,'video_url'=>url($path.$save_filename)));
}
catch (Exception $ex){
return Response::json (["Message"=>$ex->getMessage(), "code"=>$ex->getCode(), "trace"=>$ex->getTrace()]);
}