How to get an info on the video through exec(s) with ffmpeg



  • Found that code, getting it. array(0) { }

    <?
    
    exec('/usr/bin/ffmpeg -i /home/d/plush/public_html/video.mp4', $output);
    
    var_dump($output);
    

    ?>

    How is it right to get the length of the video and?


  • QA Engineer

    ffmpeg provides information on the file not on the standard conclusion (stdout(1), and to make mistakes (stderr♪ It is therefore necessary to use a reversal of errors. stdout shell2>&1😞

    <?php
     exec('/usr/bin/ffmpeg -i 1.avi 2>&1', $output);
     $duration=""; $resol="";
     foreach ($output as $s):
       if(preg_match('/Duration: ([0-9:.]+)/',$s,$m)) $duration=$m[1];
       if(preg_match('/, (\d{3,4}x\d{3,4}) /',$s,$m)) $resol=$m[1];
     endforeach;
     print("Duration: $duration Resolution: $resol\n");
    ?>
    

Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2