You are here

public function video_localcommand::get_playtime in Video 6.5

Return the playtime seconds of a video

1 call to video_localcommand::get_playtime()
video_localcommand::generate_thumbnails in transcoders/video_localcommand.inc

File

transcoders/video_localcommand.inc, line 296

Class

video_localcommand

Code

public function get_playtime($filepath) {
  $output = $this
    ->get_video_info($filepath);
  $match = array();
  if (preg_match('/Duration: ([0-9]{2}):([0-9]{2}):([0-9]{2})\\.([0-9])/', $output, $match)) {
    $hours = $match[1];
    $minutes = $match[2];
    $seconds = $match[3];
    if ($match[4] >= 5) {

      // fractional seconds
      $seconds++;
    }
    return $seconds + $hours * 3600 + $minutes * 60;
  }
  return NULL;
}