You are here

private function PHPVideoToolkit::_captureExecBuffer in Video 7

Same name and namespace in other branches
  1. 7.2 libraries/phpvideotoolkit/phpvideotoolkit.php5.php \PHPVideoToolkit::_captureExecBuffer()
3 calls to PHPVideoToolkit::_captureExecBuffer()
PHPVideoToolkit::execute in libraries/phpvideotoolkit/phpvideotoolkit.php5.php
* Commits all the commands and executes the ffmpeg procedure. This will also attempt to validate any outputted files in order to provide * some level of stop and check system. * * @access public *
PHPVideoToolkit::getFFmpegInfo in libraries/phpvideotoolkit/phpvideotoolkit.php5.php
* Returns information about the specified file without having to use ffmpeg-php * as it consults the ffmpeg binary directly. * NOTE: calling this statically for caching to work you must set the temp directory. * * @access public *
PHPVideoToolkit::getFileInfo in libraries/phpvideotoolkit/phpvideotoolkit.php5.php
* Returns information about the specified file without having to use ffmpeg-php * as it consults the ffmpeg binary directly. This idea for this function has been borrowed from * a French ffmpeg class located:…

File

libraries/phpvideotoolkit/phpvideotoolkit.php5.php, line 563

Class

PHPVideoToolkit

Code

private function _captureExecBuffer($command, $tmp_dir = false) {
  exec($command . ' 2>&1', $buffer, $err);
  if ($err !== 127) {
    if (isset($buffer[0]) === false) {
      $tmp_file = ($tmp_dir === false ? $this->_tmp_directory : $tmp_dir) . '_temp_' . uniqid(time() . '-') . '.txt';
      exec($command . ' &>' . $tmp_file, $buffer, $err);
      if ($handle = fopen($tmp_file, 'r')) {
        $buffer = array();

        // 					loop through the lines of data and collect the buffer
        while (!feof($handle)) {
          array_push($buffer, fgets($handle, 4096));
        }
      }
      @unlink($tmp_file);
    }
  }
  else {

    // 				throw ffmpeg not found error
    $buffer = array();
  }
  return $buffer;
}