我使用plupload上传视频文件到Amazon S3和我玩它使用JWPlayer。之前的视频文件播放,我显示上传到S3的视频文件列表。在这份名单中,我想显示视频的持续时间。
I am using plupload to upload video files to Amazon S3 and am playing it using JWPlayer. Before video file is played, I display list of video files uploaded to S3. In this list I would like to display the duration of the video.
我阅读了PHP中使用FFmpeg的方法。有没有更好的方式来获得持续的时间?
I have read the ffmpeg approach used with PHP. Is there a better approach to get the duration?
问候
使用 ffprobe
,以获得持续的时间。一些CLI例子,你可以适应:
Use ffprobe
to get the duration. Some cli examples you can adapt:
$ ffprobe -v error -show_entries format=duration -of default=nw=1:nk=1 input.mp4
108.501000
HH:MM:SS.MICROSECONDS
)$ ffprobe -v error -show_entries format=duration -sexagesimal -of default=nw=1:nk=1 input.mp4
0:01:48.501000