无法在 FFmpeg 中获取持续时间 laravel

Cannot get duration in FFmpeg laravel

我按照github中的命令找到了很多参考,但是return一个大对象,无法访问持续时间

这是我的代码

  $ffprobe = \FFMpeg\FFProbe::create();
  $ffprobe
      ->format($file) // extracts file informations
      ->get('duration');             // returns the duration property

  dd($ffprobe);

如果我使用 Echo 或 Return 它会给我错误

Object of class FFMpeg\FFProbe could not be converted to string

您似乎在尝试回显 FFProb 实例而不是持续时间。这个怎么样:

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

echo $duration;