本文整理汇总了PHP中Video::FastEncodeVideo方法的典型用法代码示例。如果您正苦于以下问题:PHP Video::FastEncodeVideo方法的具体用法?PHP Video::FastEncodeVideo怎么用?PHP Video::FastEncodeVideo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Video
的用法示例。
在下文中一共展示了Video::FastEncodeVideo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Image
/**
* Provide an image to the user, if he is allowed to
* see it. If $thumb is true, provide the thumb associated
* to the image.
*
* @param string $file
* @param string $thumb
* @return void
* @author Thibaud Rohmer
*/
public static function Image($file, $thumb = false, $large = false, $output = true, $dl = false)
{
if (!Judge::view($file)) {
return;
}
if (function_exists("error_reporting")) {
error_reporting(0);
}
/// Check item
$file_type = File::Type($file);
switch ($file_type) {
case "Image":
$is_video = false;
break;
case "Video":
$is_video = true;
break;
default:
return;
}
//error_log('DEBUG/Provider::image: '.$file.' '.($is_video?'is_video':''));
if (!$large) {
try {
if ($is_video) {
//TODO: fix so when opening the folder the first time no need to do F5 to see
//the freshly created thumbnail
Video::FastEncodeVideo($file);
$basefile = new File($file);
$basepath = File::a2r($file);
$path = Settings::$thumbs_dir . dirname($basepath) . "/" . $basefile->name . ".jpg";
} elseif ($thumb) {
// Img called on a video, return the thumbnail
$path = Provider::thumb($file);
} else {
$path = Provider::small($file);
}
} catch (Exception $e) {
// do nothing
}
}
if (!isset($path) || !file_exists($path)) {
error_log('ERROR/Provider::image path:' . $path . ' does not exist, using ' . $file);
$path = $file;
}
if ($output) {
if ($dl) {
header('Content-Disposition: attachment; filename="' . basename($file) . '"');
} else {
$expires = 60 * 60 * 24 * 14;
$last_modified_time = filemtime($path);
$last_modified_time = 0;
$etag = md5_file($file);
header("Last-Modified: " . 0 . " GMT");
header("Pragma: public");
header("Cache-Control: max-age=360000");
header("Etag: {$etag}");
header("Cache-Control: maxage=" . $expires);
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT');
}
header('Content-type: image/jpeg');
if (File::Type($path) == "Image") {
readfile($path);
return;
try {
imagejpeg(Provider::autorotate_jpeg($path));
} catch (Exception $e) {
error_log('ERROR/Provider.php: cannot rotate ' . $path . ': ' . $e);
readfile($path);
}
} else {
readfile($path);
}
}
}
示例2: Video
public static function Video($file, $width = '100%', $height = '100%', $control = false)
{
if (!Judge::view($file)) {
return;
}
if (function_exists("error_reporting")) {
error_reporting(0);
}
/// Check item
if (!File::Type($file) || File::Type($file) != "Video") {
return;
}
$basefile = new File($file);
$basepath = File::a2r($file);
$path_webm = Settings::$thumbs_dir . dirname($basepath) . "/" . $basefile->name . '.webm';
$c = null;
Video::FastEncodeVideo($file);
$wh = ' height="' . $height . '" width="' . $width . '"';
if ($control) {
$c = ' controls="controls"';
}
echo '<video' . $wh . $c . '><source src="' . $path_webm . '" type="video/webm" /></video>';
//echo 'Webm Video Codec not found.Plaese up to date the brower or Download the codec <a href="http://tools.google.com/dlpage/webmmf">Download</a>';
}
示例3: image
/**
* Provide an image to the user, if he is allowed to
* see it. If $thumb is true, provide the thumb associated
* to the image.
*
* @param string $file
* @param string $thumb
* @return void
* @author Thibaud Rohmer
*/
public static function image($file, $thumb = false, $large = false, $output = true, $dl = false)
{
if (!Judge::view($file)) {
return;
}
if (function_exists("error_reporting")) {
error_reporting(0);
}
/// Check item
//~ if(!File::Type($file) || File::Type($file) != "Image"){
//~ return;
//~ }
if (File::Type($file) == "Video") {
$basefile = new File($file);
$basepath = File::a2r($file);
/// Build relative path to webimg
$path = Settings::$thumbs_dir . dirname($basepath) . "/" . $basefile->name . ".jpg";
Video::FastEncodeVideo($file, $basefile->extension);
$large = true;
}
if (!$large) {
try {
if ($thumb) {
$path = File::r2a(File::a2r($file), Settings::$thumbs_dir);
if (!file_exists($path) || filectime($file) > filectime($path)) {
require_once dirname(__FILE__) . '/../phpthumb/ThumbLib.inc.php';
/// Create directories
if (!file_exists(dirname($path))) {
@mkdir(dirname($path), 0750, true);
}
/// Create thumbnail
$thumb = PhpThumbFactory::create($file);
$thumb->resize(200, 200);
$thumb->save($path);
}
} else {
list($x, $y) = getimagesize($file);
if ($x > 800 || $y > 600) {
require_once dirname(__FILE__) . '/../phpthumb/ThumbLib.inc.php';
$basefile = new File($file);
$basepath = File::a2r($file);
/// Build relative path to webimg
$webimg = dirname($basepath) . "/" . $basefile->name . "_small." . $basefile->extension;
/// Set absolute path to comments file
$path = File::r2a($webimg, Settings::$thumbs_dir);
if (!file_exists($path) || filectime($file) > filectime($path)) {
/// Create smaller image
if (!file_exists(dirname($path))) {
@mkdir(dirname($path), 0755, true);
}
$thumb = PhpThumbFactory::create($file);
$thumb->resize(800, 600);
$thumb->save($path);
}
} else {
$path = $file;
}
}
} catch (Exception $e) {
// do nothing
}
}
if (!isset($path) || !file_exists($path)) {
$path = $file;
}
if ($output) {
if ($dl) {
header('Content-Disposition: attachment; filename="' . basename($file) . '"');
header('Content-type: image/jpeg');
} else {
$expires = 60 * 60 * 24 * 14;
$last_modified_time = filemtime($path);
$last_modified_time = 0;
$etag = md5_file($file);
header("Last-Modified: " . 0 . " GMT");
header("Pragma: public");
header("Cache-Control: max-age=360000");
header("Etag: {$etag}");
header("Cache-Control: maxage=" . $expires);
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT');
header('Content-type: image/jpeg');
}
readfile($path);
}
}
示例4: upload
/**
* Upload files on the server
*
* @author Thibaud Rohmer
*/
public function upload()
{
$allowedExtensions = array("tiff", "jpg", "jpeg", "gif", "png");
/// Just to be really sure ffmpeg enable - necessary generate thumbnail jpg and webm
if (Settings::$encode_video) {
array_push($allowedExtensions, "flv", "mov", "mpg", "mp4", "ogv", "mts", "3gp", "webm");
}
$already_set_rights = false;
/// Just to be really sure...
if (!(CurrentUser::$admin || CurrentUser::$uploader)) {
return;
}
/// Set upload path
$path = stripslashes(File::r2a($_POST['path']));
/// Create dir and update upload path if required
if (strlen(stripslashes($_POST['newdir'])) > 0 && !strpos(stripslashes($_POST['newdir']), '..')) {
$path = $path . "/" . stripslashes($_POST['newdir']);
if (!file_exists($path)) {
@mkdir($path, 0750, true);
@mkdir(File::r2a(File::a2r($path), Settings::$thumbs_dir), 0750, true);
}
/// Setup rights
if (!isset($_POST['inherit'])) {
if (isset($_POST['public'])) {
Judge::edit($path);
} else {
Judge::edit($path, $_POST['users'], $_POST['groups']);
}
}
$already_set_rights = true;
}
if (!isset($_FILES["images"])) {
return;
}
/// Treat uploaded files
foreach ($_FILES["images"]["error"] as $key => $error) {
// Check that file is uploaded
if ($error == UPLOAD_ERR_OK) {
// Name of the stored file
$tmp_name = $_FILES["images"]["tmp_name"][$key];
// Name on the website
$name = $_FILES["images"]["name"][$key];
$info = pathinfo($name);
$base_name = basename($name, '.' . $info['extension']);
// Check filetype
if (!in_array(strtolower($info['extension']), $allowedExtensions)) {
continue;
}
// Rename until this name isn't taken
$i = 1;
while (file_exists("{$path}/{$name}")) {
$name = $base_name . "-" . $i . "." . $info['extension'];
$i++;
}
// Save the files
if (move_uploaded_file($tmp_name, "{$path}/{$name}")) {
// $done .= "Successfully uploaded $name";
Video::FastEncodeVideo("{$path}/{$name}");
}
/// Setup rights
if (!$already_set_rights && !isset($_POST['inherit'])) {
if (isset($_POST['public'])) {
Judge::edit($path);
} else {
Judge::edit($path, $_POST['users'], $_POST['groups']);
}
}
}
}
}