Advertisement

07.18.2008 at 11:02PM PDT, ID: 23578788 | Points: 500
[x]
Attachment Details

.mov file to .flv file conversion issue for ffmpeg

Asked by teamsunarc in Quicktime Player, PHP Scripting Language, Open Source Programming

Tags: php, ie 6.0 & firefox 3.0

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;    
}

ThanksStart Free Trial
 
Loading Advertisement...
 
[+][-]07.21.2008 at 01:07PM PDT, ID: 22053852

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.21.2008 at 08:24PM PDT, ID: 22056239

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 05:50AM PDT, ID: 22058752

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628