Melt command: how to read video properties?
How to read the total number of frames fro开发者_如何学Gom a video with "melt" command Same for time and frames per second.
Like Florin you could also do it with the command line and some dirty grep:
melt AAG_5766.MOV -consumer xml | grep length | grep -Eo '[0-9]+'
I found a possible answer to get the properties in a XML format.
Use: melt movie.flv -consumer xml
Code for php:
//get total frames and framerate
ob_start();
system('melt '.$video.' -consumer xml');
$clip_prop = ob_get_contents();
ob_end_clean();
$xml_prop = new DOMDocument();
$xml_prop->loadXML( $clip_prop );
$properties = $xml_prop->getElementsByTagName("property");
foreach( $properties as $property )
{
$attribute = $property->getAttribute("name");
//for total frames
if( $attribute == "length" )
$frames = $property->nodeValue;
//for frame rates
if( $attribute == "meta.media.0.stream.frame_rate" )
$fps = $property->nodeValue;
}
精彩评论