You are here

function _video_ffmpeg_helper_get_video_info in Video 6.2

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

Get some informations from the video file

4 calls to _video_ffmpeg_helper_get_video_info()
video_ffmpeg_helper_nodeapi in plugins/video_ffmpeg_helper/video_ffmpeg_helper.module
Implementation of hook_nodeapi()
_video_ffmpeg_helper_auto_playtime in plugins/video_ffmpeg_helper/video_ffmpeg_helper.module
Return the playtime seconds of a video
_video_ffmpeg_helper_auto_resolution in plugins/video_ffmpeg_helper/video_ffmpeg_helper.module
Return the video resolution
_video_ffmpeg_helper_auto_thumbnail in plugins/video_ffmpeg_helper/video_ffmpeg_helper.module
Generates a thumbnail from the video file

File

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

Code

function _video_ffmpeg_helper_get_video_info(&$node, $value = null) {
  static $ffmpeg_info;
  if (isset($value)) {
    $ffmpeg_info[$node->nid] = $value;
    return;
  }
  $fileobj = $node->new_video_upload_file ? $node->new_video_upload_file : _video_upload_get_file($node->new_video_upload_file_fid);

  // check if we have some info in the cache for the given node
  if (isset($ffmpeg_info[$fileobj->filename])) {
    return $ffmpeg_info[$fileobj->filename];
  }

  // escape file name for safety
  $file = escapeshellarg($fileobj->filepath);

  // create the full command to execute
  $command = variable_get('video_ffmpeg_helper_ffmpeg_path', '/usr/bin/ffmpeg') . ' -i ' . $file;

  //execute the command
  ob_start();
  passthru($command . " 2>&1", $command_return);
  $command_output = ob_get_contents();
  ob_end_clean();

  // cache the result for further calls
  $ffmpeg_info[$node->nid] = $command_output;
  return $command_output;
}