You are here

function _video_ffmpeg_helper_auto_resolution in Video 5

Same name and namespace in other branches
  1. 6 plugins/video_ffmpeg_helper/video_ffmpeg_helper.module \_video_ffmpeg_helper_auto_resolution()
  2. 6.2 plugins/video_ffmpeg_helper/video_ffmpeg_helper.module \_video_ffmpeg_helper_auto_resolution()

Return the video resolution

1 call to _video_ffmpeg_helper_auto_resolution()
video_upload_v_auto_resolution in types/video_upload/video_upload.module
Implements the hook_v_auto_resolution

File

plugins/video_ffmpeg_helper/video_ffmpeg_helper.module, line 385
Provide some api for use ffmpeg. Simplify video nodes creation.

Code

function _video_ffmpeg_helper_auto_resolution(&$node) {
  if (!$node->new_video_upload_file && !$node->new_video_upload_file_fid) {

    // no new files uploaded. skipping auto resolution process
    return null;
  }
  if (variable_get('video_ffmpeg_helper_auto_resolution', false)) {

    // call ffmpeg -i
    $ffmpeg_output = _video_ffmpeg_helper_get_video_info($node);

    // 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;
}