47 trace(
"Creating VideoManager", 3);
52 Settings::setDefaultValue(
"video",
"video_folder",
"videos", String,
"Directory inside the web folder that is used to store the video files",
"Video Uploads");
54 "Indicate whether videos should be stored under the Web Folder or in the document upload area.".
55 "If you do not have mod_xsendfile installed, then Web Folder is strongly recommended",
56 "Video Uploads",
"Web Folder\nDocument Upload Folder\nOther");
57 Settings::setDefaultValue(
"video",
"video_upload_other_location",
"", String,
"Full path to alternate video location",
"Video Uploads");
58 Settings::setDefaultValue(
"video",
"use_HTML5_video",
false, Boolean,
"Check to enable support for HTML5 video",
"Video Player",
null, 1);
59 Settings::setDefaultValue(
"video",
"use_flash_video",
true, Boolean,
"Check to enable support for old-style FLV (requires Flowplayer Flash)",
"Video Player",
null, 2);
60 Settings::setDefaultValue(
"video",
"flowplayer_script",
"", String,
"URI for the Flowplayer script",
"Video Player",
null, 3);
61 Settings::setDefaultValue(
"video",
"flowplayer_player",
"", String,
"URI for the Flowplayer SWF file",
"Video Player",
null, 4);
62 Settings::setDefaultValue(
"video",
"ffmpeg_path",
"", String,
"Directory containing the ffmpeg binary executables",
"Video Transcoder");
70 global $html_editor_extra_buttons;
74 $html_editor_extra_buttons[] =
75 array(
"name" =>
"video_picker",
76 "image" =>
"/fakoli/images/video_button.png",
77 "tooltip" =>
"Insert Video",
78 "handler" =>
"videoPicker");
88 $styles =
"<link href='//vjs.zencdn.net/4.12/video-js.css' rel='stylesheet'>" .
$styles;
89 $script =
"<script src='//vjs.zencdn.net/4.12/video.js'></script>" .
$script;
92 if ($useFlash && $flowPlayerScript)
94 $script .=
"<script type='text/javascript' src='$flowPlayerScript'></script>\n";
99 $script .=
"<script type='text/javascript'>\nvar flowplayerPath = '$flowPlayer';\n</script>\n";
109 if ($location ==
"Other")
113 if (!file_exists(
$dir))
118 else if ($location ==
"Web Folder")
121 if (!file_exists(
$dir))
129 if (!file_exists(
$dir))
146 if ($location ==
"Web Folder")
150 return "/".$folder.
"/gallery_".
$video->video_gallery_id.
"/".
$video->video_file;
154 return "/action/video/stream?video_id=".$video->video_id;
166 $mgr->upgrade($version);
169 private function getExecutablePath($exe)
172 $cmd =
$path . DIRECTORY_SEPARATOR . $exe;
181 private function execute($exe, $args)
183 if ($exe !=
"ffmpeg" && $exe !=
"ffprobe")
185 throw new Exception(
"Invalid FFMPEG executable");
188 $cmd = $this->getExecutablePath($exe);
190 if (!file_exists($cmd))
196 passthru(
"$cmd $args");
197 $out = ob_get_contents();
208 trace(
"FFMPEG: path not set", 3);
212 $ffmpeg = $this->getExecutablePath(
"ffmpeg");
213 if (!file_exists($ffmpeg))
215 trace(
"FFMPEG: no executable at $ffmpeg", 3);
219 $ffprobe = $this->getExecutablePath(
"ffprobe");
220 if (!file_exists($ffprobe))
222 trace(
"FFMPEG: no executable at $ffprobe", 3);
226 trace(
"FFMPEG: executables detected in correct location", 3);
233 trace(
"Opening video '$file'", 3);
235 if (!file_exists(
$file))
240 $this->movieFile =
$file;
241 $this->movieInfo = json_decode($this->execute(
"ffprobe",
"-v quiet -print_format json -show_format -show_streams {$this->movieFile}"));
246 foreach($this->movieInfo->streams as $stream)
248 if ($stream->codec_type ==
"video")
return $stream->width;
256 foreach($this->movieInfo->streams as $stream)
258 if ($stream->codec_type ==
"video")
return $stream->height;
266 foreach($this->movieInfo->streams as $stream)
268 if ($stream->codec_type ==
"video")
return $stream->r_frame_rate;
276 return $this->ffmpeg->getFrame($idx);
281 if (!$this->movieFile)
throw new FakoliException(
"Movie File not loaded");
285 $this->execute(
"ffmpeg",
"-ss {$offset} -i {$this->movieFile} -t 1 -s {$width}x{$height} -f image2 {$out}");
290 return intval($value) >> 1 << 1;
301 return "/action/video/thumbnail?video_id=$video_id&size=$size";
306 return "/action/video/show?image_id=$video_id";
336 $dir =
$video->VideoGallery()->getGalleryDirectory();
338 $imageFile =
$dir . DIRECTORY_SEPARATOR .
$video->image_file;
339 $cacheFile =
$dir . DIRECTORY_SEPARATOR .
$video->video_id .
"_" . $suffix .
".png";
340 trace(
"renderThumbnail:: imageFile {$imageFile} and cacheDir {$cacheDir} and cacheFile {$cacheFile}", 3);
342 if (!file_exists($cacheFile) || (filemtime($cacheFile) < filemtime($imageFile)))
344 $src = imagecreatefrompng($imageFile);
347 $fullWidth = imagesx(
$src);
348 $fullHeight = imagesy(
$src);
352 if ($fullWidth > $fullHeight)
355 $newHeight = intval(($fullHeight *
$size) / $fullWidth);
360 $newWidth = intval(($fullWidth *
$size) / $fullHeight);
367 $newHeight = intval(($fullHeight *
$width) / $fullWidth);
372 $newWidth = intval(($fullWidth *
$height) / $fullHeight);
376 $newWidth = $fullWidth;
377 $newHeight = $fullHeight;
380 trace(
"Rendering $cacheFile @ $newWidth x $newHeight", 3);
382 $dst = imagecreatetruecolor($newWidth, $newHeight);
383 imagecopyresampled($dst,
$src, 0, 0, 0, 0, $newWidth, $newHeight, $fullWidth, $fullHeight);
385 if (file_exists($cacheFile))
388 trace(
"renderThumbnail:: unlinking cachefile", 3);
392 imagepng($dst, $cacheFile);
400 trace(
"renderThumbnail:: exiting", 3);
418 $_GET[
"gallery_id"] =
$gallery->video_gallery_id;
424 if (!checkRole(
$page->role))
430 echo $pageView->drawView();
434 catch(DataNotFoundException $e)
454 trace(
"Component video is deleting objects dependent on user_id {$user_id}", 3);
456 $tx =
new DataTransaction();
475 $video->delete(
"WHERE user_id={$user_id}");
478 $download->joinTransaction(
$tx);
479 $download->delete(
"WHERE user_id={$user_id}");
499 $tx =
new DataTransaction();
510 $download->joinTransaction(
$tx);
512 $download->delete(
"WHERE video_id={$video->video_id}");
528 "Gallery" =>
"/admin/video_gallery_form",
529 "Permissions" =>
"/admin/video_gallery_permissions",
530 "Videos" =>
"/admin/videos",
531 "Statistics" =>
"/admin/video_gallery_stats",
534 $qs = ($key) ?
"video_gallery_id=$key" :
"";
535 return new TabBar(
"tabs",
$tabs,
$qs);
static findByIdentifier($identifier, $constraint="")
ComponentPageView generates the page content for a component page, substituting page fields,...
FakoliException is the base exception class for all Fakoli errors.
static detectWindowsOS()
Returns true if running on Windows, false otherwise.
static sendFile($resource)
Sends the contents of the specified file to the client.
static using()
Import the datamodels, views and manifest for the specified component(s).
static storeRedirectPage()
Store the page from which a user has been redirected when prompted to login or create an account.
static getValue($component, $name)
Retrieve the value of the specified Setting.
static setDefaultValue($component, $name, $value, $field_type="String", $annotation="", $category="", $options="", $weight=0)
Sets the default value of the given component setting.
static displayVideoGallery($identifier, &$continue)
Event handler to display an image gallery from the specified identifier.
static getVideoURI($video)
renderThumbnail($video_id, $size=0, $width=0, $height=0)
Renders the Image specified by the image_id at the specified size.
static registerTaxonomyClasses($classes)
static enumerateItems($items)
Enumerate the Image Gallery objects.
static videoGalleryTabs($key)
static formatVideoURI($video)
static deleteUser($user)
Respond to fired event DeleteUser.
static upgradeComponent($version)
static deleteGallery($gallery)
When deleting a video gallery, we must also delete all videos linked to the gallery and any downloads...
thumbnailLink($video_id, $size)
Returns the URI that can be used to access the specified thumbnail of a video at the given size.
if($config["default_content_type"]) $isAction