You are here

function zencoder_auto_playtime in Video 6.3

Return the playtime seconds of a video

1 call to zencoder_auto_playtime()
zencoder_auto_thumbnail in plugins/zencoder.inc
Generates a thumbnail from the video file Implementing hook_auto_thumbnail on inc

File

plugins/zencoder.inc, line 99
Provide a api for video conversion and auto thumbnailing using ffmpeg.

Code

function zencoder_auto_playtime($file) {
  if (!variable_get('video_zencoder_helper_auto_playtime', false)) {

    // call ffmpeg -i
    $zencoder_output = zencoder_get_video_info($file);

    // get playtime
    $pattern = '/Duration: ([0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9])/';
    preg_match_all($pattern, $zencoder_output, $matches, PREG_PATTERN_ORDER);
    $playtime = $matches[1][0];

    // ffmpeg return lenght as 00:00:31.1 Let's get playtime from that
    $hmsmm = explode(":", $playtime);
    $tmp = explode(".", $hmsmm[2]);
    $seconds = $tmp[0];
    $hours = $hmsmm[0];
    $minutes = $hmsmm[1];
    return $seconds + $hours * 3600 + $minutes * 60;
  }
}