当我尝试使用 php-ffmpeg 包装器和 ffprobe 获取视频的持续时间时,我得到一个巨大的对象,而不仅仅是持续时间。
$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');
$ffprobe
->streams($this->videoFile)
->videos()
->first()
->get('duration');
返回持续时间。所以我必须将该命令存储到一个变量中。获取持续时间的正确方法是:
$duration = $ffprobe
->streams($this->videoFile)
->videos()
->first()
->get('duration');
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)