Hello -

We are working on getting ffmeg working on our production systems and having 
trouble completing the final leg of getting the our files uploaded, processed 
and then moved to the final directory where the php code expects it.

This is the cron job php script that runs on the transcoder. The media plays 
but requires manually moving the final to the final location. Could you comment 
on the file below and suggest missing part of the command that will delete the 
input tmp file and move the output file to the final location?

Thanks!

<?
	if(!file_exists("/tmp/media_cron.pid")) {
		$_SERVER["DOCUMENT_ROOT"] = str_replace("/media_cron.php",'',__FILE__);
		require_once("application.inc.php");
		touch('/tmp/media_cron.pid');
		$loadAverageArray = sys_getloadavg();
		$currentLoadAverage = $loadAverageArray[0];
		if($currentLoadAverage < ConfigFactory::getConfigValue("load_average_threshold")) {
			$sql = "SELECT media.*
					FROM media
					WHERE has_processed = 0 
					AND file_name != ''
					AND media_type_id > 2
					LIMIT 10";
			$medias = new Medias(array("custom_sql" => $sql));
			while($media = $medias->getNext()) {
				$mediaPath = TEMP_MEDIA_PATH . trim($media->getFileName());
				if($media->getID() && $mediaPath != TEMP_MEDIA_PATH) {
					if(trim($media->getFileName()) != "") {
						switch($media->getMediaTypeID()) {
							case MEDIA_TYPE_VIDEO:
								$command = ConfigFactory::getConfigValue("ffmpeg_path") . " -y  -i " . TEMP_MEDIA_PATH . $media->getFileName() . " -threads 2 -s 320x240 -r 30.00 -threads 1 -pix_fmt yuv420p  -vcodec libx264 -vpre ultrafast -g 300  -qmin 3 -b 512k -async 50  -acodec libfaac  -ar 22050 -ac 2 -ab 192k " . MEDIA_PATH . $media->getFileName();

								shell_exec($command);
								$media->setHasProcessed(1);
								$media->save();

								unlink(TEMP_MEDIA_PATH . $media->getFileName());
								break;

							case MEDIA_TYPE_AUDIO:
								$command = ConfigFactory::getConfigValue("ffmpeg_path") . " -y -i " . TEMP_MEDIA_PATH . $media->getFileName() . " -acodec libmp3lame -ab 128k " . MEDIA_PATH . $media->getFileName();
								shell_exec($command);
								$media->setHasProcessed(1);
								$media->save();
								unlink(TEMP_MEDIA_PATH . $media->getFileName());
								break;
						}
							if(!$media->getHasProcessed()) {
									$media->setIsRetired(1);
									$media->save();
							}
					}
				}
			}

		}
		unlink('/tmp/media_cron.pid');
	}
	
?>
_______________________________________________
libav-api mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-api

Reply via email to