You are here

public function PHPVideoToolkit::setAudioCodec in Video 7.2

Same name and namespace in other branches
  1. 7 libraries/phpvideotoolkit/phpvideotoolkit.php5.php \PHPVideoToolkit::setAudioCodec()

Sets the audio format for audio outputs

@access public

Parameters

integer $audio_codec Valid values are PHPVideoToolkit::FORMAT_AAC, PHPVideoToolkit::FORMAT_AIFF, PHPVideoToolkit::FORMAT_AMR, PHPVideoToolkit::FORMAT_ASF, PHPVideoToolkit::FORMAT_MP2, PHPVideoToolkit::FORMAT_MP3, PHPVideoToolkit::FORMAT_MP4, PHPVideoToolkit::FORMAT_MPEG2, PHPVideoToolkit::FORMAT_RM, PHPVideoToolkit::FORMAT_WAV:

boolean $validate_codec Queries ffmpeg to see if this codec is available to use.:

Return value

boolean FALSE on error encountered, TRUE otherwise

File

libraries/phpvideotoolkit/phpvideotoolkit.php5.php, line 1406
Libary to access FFmpeg

Class

PHPVideoToolkit

Code

public function setAudioCodec($audio_codec, $validate_codec = TRUE) {

  //			validate input
  if (!in_array($audio_codec, array(
    self::FORMAT_AAC,
    self::FORMAT_AIFF,
    self::FORMAT_AMR,
    self::FORMAT_ASF,
    self::FORMAT_MP2,
    self::FORMAT_MP3,
    self::FORMAT_MP4,
    self::FORMAT_MPEG2,
    self::FORMAT_RM,
    self::FORMAT_WAV,
  ))) {

    // return $this->_raiseError('setAudioFormat_valid_format', array('format'=>$audio_codec));
    // <-			exits
  }

  // 			run a libmp3lame check as it require different mp3 codec
  // 			updated thanks to Varon for providing the research
  if ($audio_codec == self::FORMAT_MP3) {
    $info = $this
      ->getFFmpegInfo();
    if (isset($info['formats']['libmp3lame']) === TRUE || in_array('--enable-libmp3lame', $info['binary']['configuration']) === TRUE) {
      $audio_codec = 'libmp3lame';
    }
  }

  // 			do we need to validate this codec?
  if ($validate_codec === TRUE) {
    if ($this
      ->canCodecBeEncoded('audio', $audio_codec) === FALSE) {
      return $this
        ->_raiseError('setAudioFormat_cannnot_encode', array(
        'codec' => $audio_codec,
      ));

      // <-		   		exits
    }
  }
  return $this
    ->addCommand('-acodec', $audio_codec);
}