uberchel/mediainfo4php
Composer 安装命令:
composer require uberchel/mediainfo4php
包简介
MediaInfo is an easy-to-use static PHP class, for extracting data from audio and video files, the FFMpeg program must be installed on the sevrera or computer for the class to work.
README 文档
README
MediaInfo is an easy-to-use static PHP class, for extracting data from audio and video files, the FFMpeg program must be installed on the server or computer for the class to work. Version: 1.0.8
Requirements
- PHP >= 7.2
- PHP extensions: mbstring
- ffmpeg
Installation
No complicated installation, just transfer or copy the class file to your projector and install it using composer.
composer require uberchel/mediainfo4php
Using
The main methods Load and Get have 2 parameters, the first is the path to the file, the second is to give as an Object (default = true) For the rest, it is also possible to assign the path to the file to the first parameters if you need to find out only something specific separately or compare 2 files..
Using composer.
<?php use uberchel\MediaInfo; //use composer require __DIR__ . '/vendor/autoload.php'; //not use composer require './mediainfo.php'; $data = MediaInfo::Get('1.mkv', true); print_r($data);
We get all the metadata from the file and put it in the $data variable.
<?php $data = MediaInfo::Get('1.mkv', true); print_r($data);
Getting all the metadata from the file
<?php MediaInfo::Load('1.mkv', true);
Output the necessary data
<?php // By default, the MediaInfo4PHP class returns an Object anyway, this method supports a Boolean attribute, // by default it is set to true, and this method can also return all metadata in the selected type. // Setting the Array type for subsequent calls MediaInfo::asObject(false); // Setting the Object type for subsequent calls MediaInfo::asObject(); // The following calls will return True / False MediaInfo::isObject(); // Checking for the existence of a method value return True / False // $value - method, example: size or streams audios.size | video.size // $index - array index in streams, optional parameter MediaInfo::Has($value, $index); // Print the name, return string echo MediaInfo::GetTitle(); // Output the Size file, return string echo MediaInfo::GetSize(); // Output the Duration, return string echo MediaInfo::GetDuration(); // Output the start position, return string echo MediaInfo::GetStart(); // Output the Video Codec, return string echo MediaInfo::GetVideoCodec(); // Output the Audio Codec, return string echo MediaInfo::GetAudioCodec(); // Output the video bitrate, return string echo MediaInfo::GetBitrate(); // Output the encoder, return string echo MediaInfo::GetEncoder(); // Print the creation date, return string echo MediaInfo::GetCreated(); // Output a stream of Video, return Object or Array print_r(MediaInfo::GetVideo()); // Output an Audio stream, return Object or Array print_r(MediaInfo::GetAudios()); // Output a Subtitle stream, return Object or Array print_r(MediaInfo::GetSubtitles()); // Output a stream of Images, return Object or Array print_r(MediaInfo::GetPictures()); // Output Stream All streams, return Object or Array print_r(MediaInfo::GetStreams()); // Output All information to the stream, return Object or Array print_r(MediaInfo::Get());
Examples
Get data from video file size
<?php use uberchel\MediaInfo; require './mediainfo.php'; MediaInfo::load('./1.mkv'); if (MediaInfo::Has('size')) { echo MediaInfo::GetSize(); }
Get data from video track size
<?php use uberchel\MediaInfo; require './mediainfo.php'; MediaInfo::load('./1.mkv'); if (MediaInfo::Has('video.size')) { echo MediaInfo::GetVideo()->size; }
Get data from audio tracks
<?php use uberchel\MediaInfo; require './mediainfo.php'; MediaInfo::load('./1.mkv'); foreach (MediaInfo::GetAudios() AS $audio) { echo "ID: {$audio['id']}, Title: {$audio['title']}, Codec: {$audio['codec']}"; }
Comparing codecs of different files
<?php use uberchel\MediaInfo; require './mediainfo.php'; MediaInfo::load('./1.mkv'); print_r(MediaInfo::getVideoCodec() == MediaInfo::getVideoCodec('./2.mkv')); //The same thing without loading the Load function print_r(MediaInfo::getVideoCodec('./1.mkv') == MediaInfo::getVideoCodec('./2.mkv'));
clone the repository and install the requirements
git clone https://github.com/uberchel/MediaInfo4PHP
LICENSE
The MIT License
uberchel/mediainfo4php 适用场景与选型建议
uberchel/mediainfo4php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 04 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「parser」 「ffmpeg」 「ffprobe」 「mediainfo」 「media info」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 uberchel/mediainfo4php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 uberchel/mediainfo4php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 uberchel/mediainfo4php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Easy to use SDK with grabber for multiple platforms at once like YouTube, Dailymotion, Facebook and more.
Thumbnails for videos
An MT940 bank statement parser for PHP
Laravel integration for the jsonapi.org parser
A simple but effective command-line tool for generating thumbnails of a video, and corresponding VTT file, for use within JW Player to allow for toolbar video preview.
A modern HTML DOM parser for PHP using DOMDocument and Symfony CssSelector.
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-24