0

How to read the total number of frames from a video with "melt" command Same for time and frames per second.

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
Florin P.
  • 1
  • 3

2 Answers2

2

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]+'
dreerr
  • 25
  • 9
0

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;
}
JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
Florin P.
  • 1
  • 3