How to Get Video Metadata (Duration, Dimensions, and Size) in PHP?

Barbara Streisand
Release: 2024-11-01 06:24:02
Original
254 people have browsed it

How to Get Video Metadata (Duration, Dimensions, and Size) in PHP?

Retrieving Video Metadata in PHP: Duration, Dimensions, and Size

In PHP, obtaining vital video metadata such as duration, dimensions, and size can be achieved using reliable methods. One recommended option is integrating getID3, a library specifically designed for extracting information from media files.

Using getID3

To utilize getID3, include its PHP classes and instantiate an object to analyze the target video file:

<code class="php">include_once('pathto/getid3.php');
$getID3 = new getID3;
$file = $getID3->analyze($filename);</code>
Copy after login

From the analyzed file data, retrieve the desired metadata as follows:

<code class="php">echo("Duration: ".$file['playtime_string'].
" / Dimensions: ".$file['video']['resolution_x']." wide by ".$file['video']['resolution_y']." tall".
" / Filesize: ".$file['filesize']." bytes<br />");</code>
Copy after login

Alternative Method: ffmpeg-php

If server modification is permitted, you can install the ffmpeg-php extension. This provides a more specialized PHP interface for accessing ffmpeg's powerful media analysis capabilities.

By leveraging these techniques, you can efficiently extract essential video metadata in PHP, offering valuable insights for your applications.

The above is the detailed content of How to Get Video Metadata (Duration, Dimensions, and Size) in PHP?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!