Reputation: 1
How to read the total number of frames from a video with "melt" command Same for time and frames per second.
Upvotes: 0
Views: 733
Reputation: 1
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;
}
Upvotes: 0
Reputation: 25
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]+'
Upvotes: 2