我正在使用 laravel famework,我正在使用 ffmpeg PHP 库。如果还没有找到任何使用 ffmpeg 进行视频压缩的好链接。有两种压缩情况。
1) Video Already exists in folder - this i have done already
2) Video Upload through Form - this i am not able to do :(
让我分享第一种情况代码:-
Suppose my video is 13Mb and below code compressed to 4.5Mb (running fine)
$inputVideo = public_path('input/airplane_flight_airport_panorama_1080.mp4');
$outputVideo = public_path('uploads/output.mp4');
exec("ffmpeg -i $inputVideo -b 1000000 $outputVideo"); // this compressing or resize the video
现在第二种情况是使用表单上传:-
<form method="post" action="{{url('/api/upload-test-video')}}" enctype="multipart/form-data">
<input name="video" type="file"><br>
<input type="submit" value="Submit">
</form>
现在当我去上班时:-
public function uploadTestVideo(Request $request){
echo "<pre>"; print_r($_FILES);
// now in this function i wnat to compress the video
}
注意:-我不想在某个文件夹中上传视频,然后获取视频并压缩视频。请帮助我如何解决这个问题。提前致谢 :)