Obtaining video information using FFMPEG, or possi

2019-08-20 22:34发布

I'm making a video gallery and would like to pull some info about the video for displaying. Does anyone know how I would go about retrieving the video duration using ffmpeg? Is it possible to get this info using HTML5?

Thanks.

3条回答
▲ chillily
2楼-- · 2019-08-20 23:16

I would recommend PHPVideoToolkit...

This class is a wrapper around the FFmpeg, FLVTools2 and Mencoder programs to allow PHP developers to manipulate and convert video files in any easy to use object oriented way. It also currently provides FFmpeg-PHP emulation in pure PHP so you wouldn't need to compile and install the module. Note, it isn't intended as a FFmpeg-PHP replacement, only an alternative solution and it is recommended that if you make heavy use of the FFmpeg-PHP functionality you should install the module as it is more efficient.

PHPVideoToolkit is pretty much the only video/audio class that you will need from now on. It performs several types of manipulation operations that include video format conversion, extract video frames into separate image files, assemble a video stream from a set of separate video images, extract audio from video, watermark videos and extracted frames. Several parameters can also be configured like the output video file format (which can be Flash video or any other supported by ffmpeg), video and audio bit rate and sample rate, video dimensions and aspect ratio. It can also retrieve information about the media file, such as duration, bitrate, framerate, format, dimensions, display aspect ratio, pixel aspect ratio, audio stereo, audio frequency and audio format, without any other additional library such as ffmpeg-php.

  • Note, I wrote it so ask any questions you want about using it.
查看更多
贼婆χ
4楼-- · 2019-08-20 23:32

What I do (on Linux) is this:

tcprobe -i $FILE | tail -n1 | cut -d '=' -f3

tcprobe is from the transcode Debian package.

If you're on Windows there's a tool called MediaInfo, but I haven't tried it so I can't remark on its effectiveness.

查看更多
登录 后发表回答