How encoded series

Process directories

/usr/bin/php -f parsexml.php

parsexml.php

<?php

	$targetdirectory = "/usr/local/video/";
	$seriesprefix = "STTNG";
	$seriesnumber = "7";
	$startingepisode = 1;
   $startingextra = 1;	
	
	$vob = new 	VOBProcessor($seriesprefix,$seriesnumber,$startingepisode,$startingextra,$targetdirectory);	
	$vob->seriesprefix = "STVOY";
	$vob->seriesnumber = 1;
	$vob->startingepisode = 1;
	$vob->startingextra = 1;
	$vob->ProcessDirectory("/mnt/video/StarTrek/STVOY_S1/Disk 1");
	$vob->ProcessDirectory("/mnt/video/StarTrek/STVOY_S1/Disk 2");
	$vob->ProcessDirectory("/mnt/video/StarTrek/STVOY_S1/Disk 3");
	$vob->ProcessDirectory("/mnt/video/StarTrek/STVOY_S1/Disk 4");
	$vob->ProcessDirectory("/mnt/video/StarTrek/STVOY_S1/Disk 5");
	$vob->ProcessDirectory("/mnt/video/StarTrek/STVOY_S1/Disk 6");
	$vob->seriesprefix = "STTNG";
	$vob->seriesnumber = 7;
	$vob->startingepisode = 1;
	$vob->startingextra = 1;
	$vob->ProcessDirectory("/mnt/video/StarTrek/STTNG_S7/D1");
	$vob->ProcessDirectory("/mnt/video/StarTrek/STTNG_S7/D2");
	$vob->ProcessDirectory("/mnt/video/StarTrek/STTNG_S7/D3");
	$vob->ProcessDirectory("/mnt/video/StarTrek/STTNG_S7/D4");
	$vob->ProcessDirectory("/mnt/video/StarTrek/STTNG_S7/D5");
	$vob->ProcessDirectory("/mnt/video/StarTrek/STTNG_S7/D6");
	$vob->ProcessDirectory("/mnt/video/StarTrek/STTNG_S7/D7");
	
	class VOBProcessor {
		var $seriesprefix;
		var $seriesnumber;
		var $startingepisode;
		var $startingextra;
		var $targetdirectory;

		//constructor
		function VOBProcessor($seriesprefix,$seriesnumber,$startingepisode,$startingextra,$targetdirectory) {
			$this->seriesprefix = $seriesprefix;
			$this->seriesnumber = $seriesnumber;
			$this->startingepisode = $startingepisode;
			$this->startingextra = $startingextra;
			$this->targetdirectory = $targetdirectory;
		}

		function ProcessDirectory($dirname) {
			//fix spaces in the filename
			$dirname = str_replace(" ","\ ",$dirname);
			//create the xml file
			$xmljob = "lsdvd -a -v -Ox ".$dirname." 2>/dev/null > /tmp/parsexml.xml";
			//print  $xmljob."\n\n";
			shell_exec($xmljob);
			$this->_ProcessXML("/tmp/parsexml.xml",$dirname);
		}
	
		function _ProcessXML($filename,$dirname) {
			$doc = new DOMDocument();
			$doc->load($filename);
			
			$nodes = $doc->getElementsByTagName('track');
			foreach ($nodes as $node) {
				$length = intval($node->getElementsByTagName("length")->item(0)->nodeValue);
				$videotrack =  $node->getElementsByTagName("ix")->item(0)->nodeValue;

				if ($length > 120) {
					//print $length."\n";
					$audiotracks =  $node->getElementsByTagName("audio");
					 if ($length > 4800) {
					 	//double episode
						$episode = str_pad($this->startingepisode, 2, "0", STR_PAD_LEFT);
						$this->startingepisode++;
						$type = "E";
						$output = $this->seriesprefix."_S".$this->seriesnumber.$type.$episode;
						$episode = str_pad($this->startingepisode, 2, "0", STR_PAD_LEFT);
						$output = $output."_S".$this->seriesnumber.$type.$episode.".avi";
						$this->startingepisode++;
					 } else if ($length > 2400) {
					 	//normal episode
						$episode = str_pad($this->startingepisode, 2, "0", STR_PAD_LEFT);
						$this->startingepisode++;
						$type = "E";
						$output = $this->seriesprefix."_S".$this->seriesnumber.$type.$episode.".avi";
					} else {
						//extra feature
						$type = "X";
						$episode = str_pad($this->startingextra, 2, "0", STR_PAD_LEFT);
						$this->startingextra++;
						$output = $this->seriesprefix."_S".$this->seriesnumber.$type.$episode.".avi";
					}
					
					//try to find a 5.1audio stream else get the stereo
					$channelsfound = 0;
					$streamid = "0x00";
					foreach ($audiotracks as $audiotrack) {						
						if ($audiotrack->getElementsByTagName("langcode")->item(0)->nodeValue == "en") {				 
							$channels = intval($audiotrack->getElementsByTagName("channels")->item(0)->nodeValue);
							if ($channels == 6) {
								$channelsfound = $channels;
								$streamid = $audiotrack->getElementsByTagName("streamid")->item(0)->nodeValue;
								break;
							} else if ($channels == 2) {
								$channelsfound = $channels;
								$streamid = $audiotrack->getElementsByTagName("streamid")->item(0)->nodeValue;
							}		
						}
					}
					if ($channelsfound != 0) {
							print "./transcode_job ".$dirname." ".$videotrack." ".$streamid." ".$this->targetdirectory.$output."\n";						
					}
				}

			}
		}

	}

?>

transcode_job

transcode -H 10 -a $3 -T $2,-1,1 -x dvd,null -i "$1" -w 1800,50 -A -N 0x2000 -f 25 -j 0,0,0,0 -R 1 -y xvid,null -o /dev/null
transcode -H 10 -a $3 -T $2,-1,1 -x dvd -i "$1" -w 1800,50 -A -N 0x2000 -f 25 -j 0,0,0,0 -R 2 -y xvid -o $4 --print_status 25 
series_encoding.txt · Last modified: 2011/03/04 00:55 by 127.0.0.1
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 4.0 International
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki