Hello All,
I am having ffmpeg installed on my dedicated server and I am trying to convert the .mov, .avi, .mpeg etc formats to .flv format.
I am able to convert all these formats but some times .mov files does not convert to .flv format it shows a 0 byte .flv file but .jpg file for that particular mov fiile can be created.
I also found that the mov files which are converting successfully are running also into my windows media player and the other files which are not getting converted are not running in window media player although these all are running in quick time player.
The script which I am using is :
function ConvertToFlv($fileName)
{
$src = FILEPATH.$fileName;
$originalname = explode('.',$fileName);
$flvFileName = $originalname[0].'.flv';
$dest = FILEPATH.$flvFileName;
// To convert to the flv format
$command = escapeshellcmd("ffmpeg -i $src $dest");
$output = shell_exec($command);
return $flvFileName;
}
function CreateFlvImage($fileName)
{
// where ffmpeg is located, such as /usr/bin/ffmpeg
$ffmpeg = 'ffmpeg';
// the input video file
$video = FILEPATH.$fileName;
$originalname = explode('.',$fileName);
// where you'll save the image
$imageName = $originalname[0].'.jpg';
$image = FILEPATH. $imageName;
// default time to get the image
$second = 1;
// get the duration and a random place within that
$cmd = "$ffmpeg -i $video 2>&1";
if (preg_match('/Duration: ((\d+):(\d+):(\d+))/s', `$cmd`, $time))
{
$total = ($time[2] * 3600) + ($time[3] * 60) + $time[4];
$second = rand(1, ($total - 1));
}
// get the screenshot
$cmd = "$ffmpeg -i $video -deinterlace -an -ss $second -t 00:00:01 -r 1 -y -vcodec mjpeg -f mjpeg $image 2>&1";
$return = `$cmd`;
//returning the image name
return $imageName;
}
Thanks
Start Free Trial