Location: PHPKode > projects > VideoSplurge > includes/videoinfo.php
<?php
function movie_get_length_in_seconds($movie_filename)
{
	$cmd = "mplayer -identify -vo null -ao null -frames 1 $movie_filename 2>&1 | grep ID_LENGTH";
	$output = exec($cmd);
	list(,$length) = explode("=", $output); return $length;
}

function movie_take_screenshot($movie_filename, $time_in_seconds, $image_filename)
{
	if (mkdir(".movie.lck")) { // Try to get a lock
		$cmd = "mplayer -ss $time_in_seconds -vo jpeg -ao null -frames 2 $movie_filename 2>&1 |  grep ID_LENGTH";
		exec($cmd);
		rename("00000002.jpg", "$image_filename");
		unlink("00000001.jpg");
		rmdir(".movie.lck"); // Release lock
		return true;
	}
	else {
		return false; // Could not obtain lock
	}
}

//$movie_filename = "test.mpg";
//$movie_length = movie_get_length_in_seconds($movie_filename);
//$random_seconds = rand(0, floor($movie_length));
//$was_image_created = movie_take_screenshot($movie_filename, $random_seconds, "test_image.jpg");
?>
Return current item: VideoSplurge