You are here

private function video_ffmpeg::run_command in Video 6.4

Same name and namespace in other branches
  1. 7 transcoders/video_ffmpeg.inc \video_ffmpeg::run_command()

Run the specified command

The nice prefix is automatically added. The command is logged if the settings specify that all commands should be logged. The command and error are logged if the command results in an error

Parameters

string $command:

string $output Output of the command:

string $purpose Purpose of the command. This is logged.:

bool $ignoreoutputfilenotfound Whether to the output file not found error. Useful for input file information.:

3 calls to video_ffmpeg::run_command()
video_ffmpeg::convert_video in transcoders/video_ffmpeg.inc
video_ffmpeg::generate_thumbnails in transcoders/video_ffmpeg.inc
video_ffmpeg::get_video_info in transcoders/video_ffmpeg.inc
Get some information from the video file

File

transcoders/video_ffmpeg.inc, line 38

Class

video_ffmpeg

Code

private function run_command($command, &$output, $purpose = NULL, $ignoreoutputfilenotfound = FALSE) {
  $output = '';
  $command = $this->nice . $command . ' 2>&1';
  $purposetext = !empty($purpose) ? ' ' . t('for') . ' ' . $purpose : '';
  if ($this->logcommands) {
    watchdog('video_ffmpeg', 'Executing ffmpeg command!purposetext: <pre>@command</pre>', array(
      '@command' => $command,
      '!purposetext' => $purposetext,
    ), WATCHDOG_DEBUG);
  }
  $return_var = 0;
  ob_start();
  passthru($command, $return_var);
  $output = ob_get_clean();

  // Returnvar 1 means input file not found. This is normal for information calls.
  if ($return_var != 0 && ($return_var != 1 || !$ignoreoutputfilenotfound)) {
    watchdog('video_ffmpeg', 'Error executing ffmpeg command!purposetext:<br/><pre>@command</pre>Output:<br/><pre>@output</pre>', array(
      '@command' => $command,
      '@output' => trim($output),
      '!purposetext' => $purposetext,
    ), WATCHDOG_ERROR);
    return FALSE;
  }
  return TRUE;
}