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

Patricia Arquette
Release: 2024-10-30 19:59:03
Original
349 people have browsed it

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

Determining Video Duration, Dimensions, and Size in PHP

Extracting video metadata such as duration, dimensions, and size is a common task when processing video files. This article demonstrates how to accomplish this in PHP.

Utilizing getID3

getID3 is a PHP library that supports video format analysis. To use it:

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

The extracted metadata can be accessed 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

Employing ffmpeg-php

If server modifications are allowed, install the ffmpeg-php extension:

http://ffmpeg-php.sourceforge.net/
Copy after login

This extension provides a more comprehensive API for video analysis.

The above is the detailed content of How to Get Video 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