2017-05-11 5 views
1

php-ffmpeg 래퍼와 ffprobe를 사용하여 비디오의 재생 시간을 가져 오려고하면 재생 시간 대신 커다란 물체가 나타납니다.php-ffmpeg 비디오 길이 가져 오기

$ffprobe = FFMpeg\FFProbe::create(); 
    $ffprobe->format($this->videoFile) 
      ->get('duration'); 

$ this-> videoFile는 /home/admin/........./5422346433.mp4

그래서 그것은 바로 파일을 가리키는 및 기간이 거대한 물체에 나열되어 있습니다 아래로

[[-show_format-/home/admin/web/admin.simplewebevents.com/public_html/cron/649652027.mp4][1]] => Array 
        (
         [0] => FFMpeg\FFProbe\DataMapping\Format Object 
          (
           [properties:FFMpeg\FFProbe\DataMapping\AbstractData:private] => Array 
            (
             [filename] => /home/admin/web/admin.simplewebevents.com/public_html/cron/649652027.mp4 
             [nb_streams] => 2 
             [nb_programs] => 0 
             [format_name] => mov,mp4,m4a,3gp,3g2,mj2 
             [format_long_name] => QuickTime/MOV 
             [start_time] => 0.000000 
             [duration] => 5736.833333 
             [size] => 668381267 
             [bit_rate] => 932056 
             [probe_score] => 100 
             [tags] => Array 
              (
               [major_brand] => mp42 
               [minor_version] => 0 
               [compatible_brands] => mp42mp41isomavc1 
               [creation_time] => 2016-12-04 18:25:58 
              ) 

            ) 

          ) 

         [1] => 
        ) 

      ) 

하지만 분명히 -> get ('duration')은 기간을 반환하지 않습니다.

또한

$ffprobe 
->streams($this->videoFile) // extracts streams informations 
->videos()      // filters video streams 
->first()      // returns the first video stream 
->get('duration'); 

답변

2
$ffprobe 
    ->streams($this->videoFile) 
    ->videos()     
    ->first()     
    ->get('duration'); 

이 기간을 반환으로 시도했습니다. 그래서 나는 그 명령을 변수에 저장해야한다. 기간을 가져 오는 올바른 방법은 다음과 같습니다.

$duration = $ffprobe 
      ->streams($this->videoFile) 
      ->videos()     
      ->first()     
      ->get('duration');