You are here

function ffmpeg_wrapper_auto_resolution in Video 6.3

Return the video resolution

File

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

Code

function ffmpeg_wrapper_auto_resolution(&$vidfile) {
  if (!variable_get('video_ffmpeg_helper_auto_resolution', false)) {

    // call ffmpeg -i
    $filepath = escapeshellarg($vidfile['filepath']);
    $ffmpeg_output = ffmpeg_wrapper_file_data($filepath);

    // get resolution
    $pattern = '/Video: .*, ([0-9]{2,4}x[0-9]{2,4})/';
    preg_match_all($pattern, $ffmpeg_output, $matches, PREG_PATTERN_ORDER);
    $resolution = $matches[1][0];
    return explode("x", $resolution);
  }
  return null;
}