Defolt
PHP+ffmpeg
Две функции. Первая для WMV. Вторая для FLV.
Вывод в виде массива $info.
<?
function get_vid_info_wmv($file)
{
$command = 'C:\ffmpeg\bin\ffmpeg.exe -i ' . escapeshellarg($file) . ' 2>&1';
$info = array();
exec($command,$output,$status);
$imp=implode('\n',$output);
//Seems stream 1 codec frame rate differs from container frame rate: 1000.00 (1000/1) -> 30.00 (30/1)
preg_match('/Seems stream [0-9] codec frame rate differs from container frame rate: 1000.00 \(1000\/1\) -> (?P<framerate>[0-9][0-9])/',$imp,$matches0);
preg_match('/Stream #(?:[0-9\.]+)(?:.*)\: Video: (?P<videocodec>.*) (?P<width>[0-9]*)x(?P<height>[0-9]*)/',$imp,$matches1);
preg_match('/Duration\: (?P<duration>[0-9]*\:[0-9]*\:[0-9]*)[\s.][0-9]*[\s,] start\: [0-9]*[\s.][0-9]*[\s,] bitrate\: (?P<bitrate>[0-9]*)/',$imp,$matches2);
preg_match('/Stream #(?:[0-9\.]+)(?:.*)\: Audio: (?P<audiocodec>[a-z0-9]*)[\s,] (?P<Hz>[0-9]*) [a-zA-Z]{2}[\s,] (?P<channels>[0-9]*) [a-z]*[\s,] [a-z0-9]*[\s,] (?P<audiobitrate>[0-9]*)/',$imp,$matches3);
$info['framerate'] = $matches0['framerate'];
$info['videocodec'] = $matches1['videocodec'];
$info['width'] = $matches1['width'];
$info['height'] = $matches1['height'];
$info['duration'] = $matches2['duration'];
$info['bitrate'] = $matches2['bitrate'];
$info['audiocodec'] = $matches3['audiocodec'];
$info['Hz'] = $matches3['Hz'];
$info['channels'] = $matches3['channels'];
$info['audiobitrate'] = $matches3['audiobitrate'];
return $info;
}
function get_vid_info_flv($file)
{
$command = 'C:\ffmpeg\bin\ffmpeg.exe -i ' . escapeshellarg($file) . ' 2>&1';
$info = array();
exec($command,$output,$status);
$imp=implode('\n',$output);
preg_match('/Stream #(?:[0-9\.]+)(?:.*)\: Video: (?P<videocodec>.*) (?P<width>[0-9]*)x(?P<height>[0-9]*)/',$imp,$matches1);
preg_match('/Duration\: (?P<duration>[0-9]*\:[0-9]*\:[0-9]*)[\s.][0-9]*[\s,] start\: [0-9]*[\s.][0-9]*[\s,] bitrate\: (?P<bitrate>[0-9]*)/',$imp,$matches2);
preg_match('/Stream #(?:[0-9\.]+)(?:.*)\: Audio: [a-z_A-Z]*[\s,] (?P<Hz>[0-9]*) [a-zA-Z]{2}[\s,] (?P<channels>[0-9]*) [a-z]*[\s,] [a-z0-9]*[\s,] (?P<audiobitrate>[0-9]*)/',$imp,$matches3);
$info['width'] = $matches1['width'];
$info['height'] = $matches1['height'];
$info['duration'] = $matches2['duration'];
$info['bitrate'] = $matches2['bitrate'];
$info['Hz'] = $matches3['Hz'];
$info['channels'] = $matches3['channels'];
$info['audiobitrate'] = $matches3['audiobitrate'];
return $info;
}
?>