You are here

public function PHPVideoToolkit::setVideoCodec in Video 7.2

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

Forces the video format for video outputs to a specific codec. This should not be confused with setFormat. setVideoFormat does not generally need to be called unless setting a specific video format for a type of media format. It gets a little confusing...

@access public

Parameters

integer $video_codec Valid values are PHPVideoToolkit::FORMAT_3GP2, PHPVideoToolkit::FORMAT_3GP, PHPVideoToolkit::FORMAT_AVI, PHPVideoToolkit::FORMAT_FLV, PHPVideoToolkit::FORMAT_GIF, PHPVideoToolkit::FORMAT_MJ2, PHPVideoToolkit::FORMAT_MP4, PHPVideoToolkit::FORMAT_MPEG4, PHPVideoToolkit::FORMAT_M4A, PHPVideoToolkit::FORMAT_MPEG, PHPVideoToolkit::FORMAT_MPEG1, PHPVideoToolkit::FORMAT_MPEG2, PHPVideoToolkit::FORMAT_MPEGVIDEO:

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 1439
Libary to access FFmpeg

Class

PHPVideoToolkit

Code

public function setVideoCodec($video_codec, $validate_codec = TRUE) {

  //			validate input
  if (!in_array($video_codec, array(
    self::FORMAT_3GP2,
    self::FORMAT_3GP,
    self::FORMAT_AVI,
    self::FORMAT_FLV,
    self::FORMAT_GIF,
    self::FORMAT_MJ2,
    self::FORMAT_MP4,
    self::FORMAT_MPEG4,
    self::FORMAT_M4A,
    self::FORMAT_MPEG,
    self::FORMAT_MPEG1,
    self::FORMAT_MPEG2,
    self::FORMAT_MPEGVIDEO,
  ))) {

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

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

      // <-		   		exits
    }
  }
  if ($video_codec == 'libtheora') {

    // Special case for libtheora which demands the frame size to be multiples of 16x16
    $this->width_multiple = 16;
    $this->height_multiple = 16;
  }
  else {
    $this->width_multiple = 0;
    $this->height_multiple = 0;
  }
  return $this
    ->addCommand('-strict experimental -vcodec', $video_codec);
}