/** * Generates an MKVMerge command for the video file $videoFile * @param string $videoFile */ public function doGenerateCommand() { $result = new ezcMvcResult(); $videoFile = $this->VideoFile; $episodeFile = new TVEpisodeFile( $videoFile ); $result->variables['status'] = 'ok'; $commandGenerator = new MKVMergeCommandGenerator(); // add audio + video in english, and disable existing subtitles foreach( $commandGenerator->addInputFile( new MKVMergeMediaInputFile( $episodeFile->path ) ) as $track ) { if ( $track instanceof MKVmergeCommandSubtitleTrack ) { $track->enabled = false; } else { $track->language = 'eng'; $track->default_track = true; } } // add subtitle file if ( $episodeFile->hasSubtitleFile ) { foreach( $commandGenerator->addInputFile( new MKVMergeSubtitleInputFile( $episodeFile->subtitleFile, 'fre' ) ) as $track ) { $track->language = 'fre'; $track->default_track = true; } } // determine best disk $bestFit = mmMkvManagerDiskHelper::BestTVEpisodeFit( $episodeFile->fullname, $episodeFile->fileSize ); if ( isset( $bestFit['RecommendedDiskHasFreeSpace'] ) && $bestFit['RecommendedDiskHasFreeSpace'] === 'true' ) $disk = $bestFit['RecommendedDisk']; else $disk = 'VIMES'; $commandGenerator->setOutputFile( "/media/storage/{$disk}/TV Shows/{$episodeFile->showName}/{$episodeFile->filename}" ); $commandObject = $commandGenerator->get(); $commandObject->appendSymLink = true; $result->variables['command'] = $commandObject->asString(); return $result; }
/** * Merge interface for movies * @param string $this->Folder The name of the movie folder */ public function doMovieMerge() { $moviesPath = ezcConfigurationManager::getInstance()->getSetting( 'movies', 'GeneralSettings', 'SourcePath' ); $result = new ezcMvcResult; $result->variables['page_title'] = "{$this->Folder} :: Movies :: MKV Manager"; $result->variables['movie'] = $this->Folder; $generator = new MKVMergeCommandGenerator(); // video file, mandatory $videoFiles = glob( "{$moviesPath}/{$this->Folder}/{$this->Folder}.{mkv,avi}", GLOB_BRACE ); if ( !count( $videoFiles ) ) { throw new InvalidArgumentException( "No files found matching pattern {$moviesPath}/{$this->Folder}/{$this->Folder}.{mkv,avi}" ); } $videoFiles = $videoFiles[0]; $generator->addInputFile( new MKVMergeMediaInputFile( $videoFiles ) ); // subtitle file(s), optional $subtitlesFiles = glob( "{$moviesPath}/{$this->Folder}/{$this->Folder}*.{srt,avi}", GLOB_BRACE ); if ( count( $subtitlesFiles ) ) { } foreach( $subtitlesFiles as $subtitlesFile ) { $generator->addInputFile( new MKVMergeSubtitleInputFile( $subtitlesFile, 'und' ) ); } $tracks = array(); foreach ( $generator->trackSets as $trackSet ) { foreach ( $trackSet as $track ) { $tracks[] = $track; } } // output file $generator->setOutputFile( "/media/storage/VIMES/Movies/{$this->Folder}/{$this->Folder}.mkv" ); $result->variables['tracks'] = $tracks; $result->variables['command'] = $generator->getCommandString(); $result->variables += mmApp::doMovies(); return $result; }
public function testGenerateRealTVMKV() { self::markTestSkipped(); $mkvFile = '/home/download/downloads/complete/TV/Sorted/Californication/Californication - 4x09 - Another Perfect Day.mkv'; $assFile = '/home/download/downloads/complete/TV/Sorted/Californication/Californication - 4x09 - Another Perfect Day.ass'; $generator = new MKVMergeCommandGenerator(); foreach( $generator->addInputFile( new MKVMergeMediaInputFile( $mkvFile ) ) as $commandTrack ) { $commandTrack->language = 'eng'; } foreach( $generator->addInputFile( new MKVMergeMediaInputFile( $assFile ) ) as $commandTrack ) { $commandTrack->language = 'fre'; } $generator->setOutputFile( '/media/storage/CARROT/TV Shows/Californication/Californication - 4x09 - Another Perfect Day.mkv' ); $command = $generator->getCommandString(); // echo $command; }