使用ffmpeg
|
|
- 安装ffmpeg
|
|
使用命令行获取文件信息
1234567891011ffmpeg -i 庞麦郎_-_我的滑板鞋.mp4Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '庞麦郎_-_我的滑板鞋.mp4':Metadata:major_brand : isomminor_version : 512compatible_brands: isomiso2avc1mp41encoder : Lavf54.6.100Duration: 00:03:36.48, start: 0.000000, bitrate: 2778 kb/sStream #0.0(und): Video: h264, yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 2674 kb/s, 25 fps, 25 tbr, 25025 tbn, 50 tbcStream #0.1(und): Audio: aac, 44100 Hz, stereo, s16, 97 kb/sAt least one output file must be specified使用正则提取需要的信息
1234567891011121314151617181920212223242526function getVideoFormat($file){$ffmpeg = "/usr/bin/ffmpeg";ob_start();passthru(sprintf($ffmpeg.' -i "%s" 2>&1', $file));$info = ob_get_contents();ob_end_clean();preg_match('/Video:\s(?<format>.*?),/', $info, $match);return $match;}$file = __DIR__ . '/庞麦郎_-_我的滑板鞋.mp4';var_dump(getVideoFormat($file));/*array(3) {[0]=>string(12) "Video: h264,"["format"]=>string(4) "h264"[1]=>string(4) "h264"}*/
使用getID3类库
|
|