You are here

public static function TranscoderAbstractionFactoryFfmpeg::getVersionFromOutput in Video 7.2

Returns the FFmpeg version string from an output string.

FFmpeg returns its version in the output of almost any call.

Used instead of PHPVideoToolkit::getVersion(), because PHPVideoToolkit has not been updated and does not support git versions.

Parameters

string containing output of ffmpeg -version:

Return value

string containing version of FFmpeg

3 calls to TranscoderAbstractionFactoryFfmpeg::getVersionFromOutput()
TranscoderAbstractionFactoryFfmpeg::adminSettingsValidate in transcoders/TranscoderAbstractionFactoryFfmpeg.inc
Validate admin settings. This will call when Drupal admin settings validate.
TranscoderAbstractionFactoryFfmpeg::getVersion in transcoders/TranscoderAbstractionFactoryFfmpeg.inc
Get the installed transcoder version.
TranscoderAbstractionFactoryFfmpegTestCase::testVersionInfo in tests/TranscoderAbstractionFactoryFfmpeg.test
Test of TranscoderAbstractionFactoryFfmpeg::getVersionFromOutput()

File

transcoders/TranscoderAbstractionFactoryFfmpeg.inc, line 623
File containing class TranscoderAbstractionFactoryFfmpeg

Class

TranscoderAbstractionFactoryFfmpeg
Class that handles FFmpeg transcoding.

Code

public static function getVersionFromOutput($output, &$ffmpegoravconv) {
  $version = NULL;
  $ffmpegoravconv = NULL;
  $matches = array();

  // Git check outs
  if (preg_match('/(ffmpeg|avconv) version N-\\d+-g([a-f0-9]+)/', $output, $matches)) {
    $ffmpegoravconv = $matches[1];
    $version = 'git: ' . $matches[2];
  }
  elseif (preg_match('/(ffmpeg|avconv) version git-(\\d{4}-\\d{2}-\\d{2}-[a-f0-9]+)/', $output, $matches)) {
    $ffmpegoravconv = $matches[1];
    $version = 'git: ' . $matches[2];
  }
  elseif (preg_match('/(ffmpeg|avconv) version ([0-9.]+)/i', $output, $matches)) {
    $ffmpegoravconv = $matches[1];
    $version = $matches[2];
  }
  elseif (preg_match('/(ffmpeg|avconv) version ([^\\n]+)/i', $output, $matches)) {
    $ffmpegoravconv = $matches[1];
    $version = $matches[2];
    if (($pos = strpos($version, ' Copyright')) !== FALSE) {
      $version = drupal_substr($version, 0, $pos);
    }
    $version = t('unrecognized: !version', array(
      '!version' => $version,
    ));
  }
  if ($ffmpegoravconv == 'ffmpeg') {
    $ffmpegoravconv = 'FFmpeg';
  }
  return $version;
}