I am having a live video streaming website and I allow people to upload all the video files to the site till now everything is ok.
What I am doing is that I am using FFMPEG to convert the video to mp4 and also get a image out of the video after 20 seconds.
The code that I am using is that:
require 'vendor/autoload.php';
$getEXT_check=substr(@$_FILES['profileimage99']['name'],-3);
if($getEXT_check !='mp4' && $getEXT_check !='MP4'){
exec('ffmpeg -i '.$uploadfile.' -f mp4 -s 896x504 '.$new_flv.''); }
//execute ffmpeg and create thumb
exec('ffmpeg -i '.$uploadfile.' -ss 00:00:20 -vframes 1 '.$new_image_path);
$theduration=exec('ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 '.$uploadfile.' 2>&1');
$theduration_val=round($theduration/60, 2);
What issue I am having is that
- sometimes the code dosent extract the image out of video
- video conversation takes very long time for non mp4 video (I am not converting mp4 videos)
Some info what I have done on server. During the development of site I installed ffmpeg on my pc and downloaded the vendor directory by composer.json file. But I have not done these things on my server I have a dedicated server from bluehost and have ffmpeg installed at this location.
/usr/local/bin/ffmpeg
/usr/local/bin/mplayer
/usr/local/bin/mencoder
/usr/bin/flvtool2
/usr/local/bin/MP4Box
/usr/local/bin/yamdi
During uploading the site what I did is that I also uploaded the vendor directory and all the files and made the site live. I haven't used any of the path as given by my server admin after asking.
Please suggest me something where I am doing wrong.