PHP5 Video conversion class

This is a snippet of a bunch of classes I wrote to handle video conversion, for a 'YouTube' clone-type site. It was using MEncoder and FFMPEG to convert the videos.



class videoConversionClass
{
	const FFMPEG_PATH	= '/usr/local/bin/ffmpeg';
	const MENCODER_PATH	= '/usr/local/bin/mencoder';
	
	public $setFormat;
	public $inputFile;
	public $dimensionsWidth;
	public $dimensionsHeight;
	public $audioCodec;
	public $audioBitrate;
	public $audioSamplingRate;
	public $bitrate;
	public $outputfile;
	
	public function __construct()
	{
		
	}
	
	public function __destruct()
	{
		
	}
	
	
	/*
	 * 
	 * 
	 * 
	 */
	public function convertToFLV()
	{
		$this->setFormat = 'flv';
		
	}
	
	/**
	 * 
	 * Sets the format to FLV
	 * 
	 * @param integer $audio_sample_frequency
	 * @param integer $audio_bitrate
	 */
	public function setFormatToFLV($params = array())
	{
		$this->addCommand('-sameq');
		$this->addCommand('-acodec', 'mp3');
		
		$this->setAudioBitRate($audio_bitrate);
		$this->setAudioSampleFrequency($audio_sample_frequency);
		
		$this->setFormat(FFMPEG_FORMAT_FLV);
		
		$this->flv_conversion = TRUE;
	}

	
	/**
	 * Returns the server MAC address if possible, via shell
	 *
	 * @return string the MAC address
	 */
	static public function returnMacAddress() {
		
		$location = `which arp`;
		$location = rtrim($location);
		
		$arpTable = `$location -n`;
		
		$arpSplitted = split("\n",$arpTable);
		
		$remoteIp = $_SERVER['REMOTE_ADDR'];
		$remoteIp = str_replace(".", "\\.", $remoteIp);
		
		foreach ($arpSplitted as $value) {
			$valueSplitted = split(" ",$value);
		
			foreach ($valueSplitted as $spLine) {
				if ( preg_match("/$remoteIp/",$spLine) ) {
					$ipFound = true;
				}
			
				if ($ipFound) {
	
					reset($valueSplitted);
			
					foreach ($valueSplitted as $spLine) {
						if (preg_match("/[0-9a-f][0-9a-f][:-][0-9a-f][0-9a-f][:-][0-9a-f][0-9a-f][:-][0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f][:-][0-9a-f][0-9a-f]/i",$spLine)) {
							return $spLine;
						}
					}	
				}
				$ipFound = false;
			}
		}
		return false;
	}
	
	/**
	 * Concatenates the width and height for ffmpeg
	 * 
	 * @return string concatenated width and height into string
	 * @access public
	 */
	static public function getDimensions()
	{
		return $this->dimensionsWidth.'x'.$this->dimensionsHeight;
	}
}



click here to add a comment