aboutsummaryrefslogtreecommitdiff
path: root/transcoders
diff options
context:
space:
mode:
authorSilvio <silvio@devlet.com.br>2011-07-27 16:26:39 -0300
committerSilvio <silvio@devlet.com.br>2011-07-27 16:26:39 -0300
commit1f2d2790eed7f5bec84e52e63dc40d46ef170150 (patch)
tree00583c4ee789ddd79c2f0b1b6089e6b5708fd0e4 /transcoders
parent93c4026ed234463e58ab610776202e2386fd601d (diff)
downloadvideo-1f2d2790eed7f5bec84e52e63dc40d46ef170150.tar.gz
video-1f2d2790eed7f5bec84e52e63dc40d46ef170150.tar.bz2
Checks if ffmpeg extension is available at video_ffmpeg_php transcoder
Diffstat (limited to 'transcoders')
-rw-r--r--transcoders/video_ffmpeg_php.inc40
1 files changed, 36 insertions, 4 deletions
diff --git a/transcoders/video_ffmpeg_php.inc b/transcoders/video_ffmpeg_php.inc
index 2569616..f22c6cb 100644
--- a/transcoders/video_ffmpeg_php.inc
+++ b/transcoders/video_ffmpeg_php.inc
@@ -22,6 +22,25 @@ class video_ffmpeg_php extends video_ffmpeg implements transcoder_interface {
}
/**
+ * Load a movie.
+ *
+ * @param $videopath
+ * Video file path.
+ *
+ * @return
+ * An ffmpeg_movie object on success, FALSE otherwise.
+ */
+ private function load_movie($videopath) {
+ if(!extension_loaded('ffmpeg')) {
+ $error_msg = t("Extension ffmpeg-php not available.");
+ watchdog('transcoder', $error_msg, array(), WATCHDOG_ERROR);
+ return FALSE;
+ }
+
+ return new ffmpeg_movie($videopath);
+ }
+
+ /**
* Generate video thumbs.
*/
public function generate_thumbnails($video) {
@@ -48,7 +67,12 @@ class video_ffmpeg_php extends video_ffmpeg implements transcoder_interface {
//skip files already exists, this will save ffmpeg traffic
if (!is_file(drupal_realpath($thumbfile))) {
// Use PHP-FFMPEG
- $movie = new ffmpeg_movie($videopath);
+ $movie = $this->load_movie($videopath);
+
+ if (!$movie) {
+ return $files;
+ }
+
$frames = $movie->getFrameCount();
$fps = $movie->getFrameRate();
@@ -88,15 +112,23 @@ class video_ffmpeg_php extends video_ffmpeg implements transcoder_interface {
* Return the playtime seconds of a video
*/
public function get_playtime($video) {
- $movie = new ffmpeg_movie($video);
- return $movie->getDuration();
+ $movie = $this->load_movie($video);
+ return (!$movie) ? 0 : $movie->getDuration();
}
/**
* Return the dimensions of a video
*/
public function get_dimensions($video) {
- $movie = new ffmpeg_movie($video);
+ $movie = $this->load_movie($video);
+
+ if (!$movie) {
+ return array(
+ 'width' => 0,
+ 'height' => 0,
+ );
+ }
+
$res['width'] = $movie->getFrameWidth();
$res['height'] = $movie->getFrameHeight();
return $res;