Login   Register  
PHP Classes
elePHPant
Icontem

File: src/PHPVideoToolkit/VideoFormat/H264.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Oliver Lillie  >  PHP Video Toolkit  >  src/PHPVideoToolkit/VideoFormat/H264.php  >  Download  
File: src/PHPVideoToolkit/VideoFormat/H264.php
Role: Class source
Content type: text/plain
Description: Class source
Class: PHP Video Toolkit
Manipulate and convert videos with ffmpeg program
Author: By
Last change: updated copy right years and a incorrect version number
updated version number in class files
removed incorrect copied function calls
Date: 3 months ago
Size: 3,362 bytes
 

Contents

Class file image Download
<?php
    
    
/**
     * This file is part of the PHP Video Toolkit v2 package.
     *
     * @author Oliver Lillie (aka buggedcom) <publicmail@buggedcom.co.uk>
     * @license Dual licensed under MIT and GPLv2
     * @copyright Copyright (c) 2008-2014 Oliver Lillie <http://www.buggedcom.co.uk>
     * @package PHPVideoToolkit V2
     * @version 2.1.1
     * @uses ffmpeg http://ffmpeg.sourceforge.net/
     */
     
     
namespace PHPVideoToolkit;

    
/**
     * @access public
     * @author Oliver Lillie
     * @package default
     */
    
class VideoFormat_H264 extends VideoFormat
    
{
        protected 
$_restricted_video_presets;
        
        public function 
__construct($input_output_typeConfig $config=null)
        {
            
parent::__construct($input_output_type$config);
            
            
$this->_format array_merge($this->_format, array(
                
'h264_preset' => null,
                
'h264_tune' => null,
                
'h264_constant_quantization' => null,
            ));
            
$this->_format_to_command array_merge($this->_format_to_command, array(
                
'h264_preset' => '-preset <setting>',
                
'h264_tune' => '-tune <setting>',
                
'h264_constant_quantization' => '-qp <setting>',
            ));
            
            
$this->_restricted_video_presets null;
            
            if(
$input_output_type === 'output')
            {
                
$this->setAudioCodec('mp3')
                     ->
setVideoCodec('h264')
                     ->
setFormat('h264');
            }
        }
        
        public function 
setH264Preset($preset=null)
        {
            
$this->_blockSetOnInputFormat('h264 preset');
            
            if(
$preset === null)
            {
                
$this->_format['h264_preset'] = null;
                return 
$this;
            }
            
            if(
in_array($preset, array('ultrafast''superfast''veryfast''faster''fast''medium''slow''slower''veryslow''placebo')) === false)
            {
                throw new 
Exception('Unrecognised h264 preset "'.$preset.'" set in \\PHPVideoToolkit\\'.get_class($this).'::setH264Preset');
            }
            
            
$this->_format['h264_preset'] = $preset;
            return 
$this;
        }
        
        public function 
setH264Tune($tune=null)
        {
            
$this->_blockSetOnInputFormat('h264 tune');
            
            if(
$tune === null)
            {
                
$this->_format['h264_tune'] = null;
                return 
$this;
            }
            
            if(
in_array($tune, array('film''animation''grain''stillimage''psnr''ssim''fastdecode''zerolatency')) === false)
            {
                throw new 
Exception('Unrecognised h264 preset "'.$preset.'" set in \\PHPVideoToolkit\\'.get_class($this).'::setH264Tune');
            }
            
            
$this->_format['h264_tune'] = $tune;
            return 
$this;
        }
        
        public function 
enableH264LosslessEncoding()
        {
            
$this->_format['h264_constant_quantization'] = 0;
            return 
$this;
        }
        
        public function 
disableH264LosslessEncoding()
        {
            
$this->_format['h264_constant_quantization'] = null;
            return 
$this;
        }
    }