aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/filesystem.inc128
-rw-r--r--modules/video_ui/video.admin.inc17
-rw-r--r--modules/video_ui/video.preset.inc3
-rw-r--r--modules/video_ui/video_ui.module19
-rw-r--r--transcoders/video_ffmpeg.inc38
-rw-r--r--video.field.inc22
-rw-r--r--video.module12
7 files changed, 53 insertions, 186 deletions
diff --git a/includes/filesystem.inc b/includes/filesystem.inc
deleted file mode 100644
index d2d2fd9..0000000
--- a/includes/filesystem.inc
+++ /dev/null
@@ -1,128 +0,0 @@
-<?php
-
-/*
- * @file
- * Class file used to store video in the filesyetm as CDN or local.
- *
- */
-
-class video_filesystem {
-
- private $filesystem;
-
- public function __construct($filesystem = null) {
- //get our configured transcoder.
- if (!isset($filesystem))
- $filesystem = variable_get('video_filesystem', 'drupal');
- if (!module_load_include('inc', 'video', '/filesystem/' . $filesystem)) {
- $modules = module_list();
- foreach ($modules as $module) {
- $mobule_files = array();
- $module_path = drupal_get_path('module', $module) . '/filesystem';
- $mobule_files = file_scan_directory($module_path, '/.*\.inc/');
- if (is_array($mobule_files)) {
- foreach ($mobule_files as $file) {
- if ($file->name == $filesystem)
- require_once $file->filename;
- }
- }
- }
- }
- if (class_exists($filesystem)) {
- $this->filesystem = new $filesystem;
- } else {
- drupal_set_message(t('The filesystem is not configured properly.'), 'error');
- }
- }
-
- public function save_file($video) {
- return $this->filesystem->save_file($video);
- }
-
- public function prepare_file($video) {
- return $this->filesystem->prepare_file($video);
- }
-
- public function load_file(&$video) {
- return $this->filesystem->load_file($video);
- }
-
- public function admin_settings() {
- $form = array();
- $options = $this->_filesystem();
- $form['video_filesystem'] = array(
- '#type' => 'radios',
- '#title' => t('Video Filesystem'),
- '#default_value' => variable_get('video_filesystem', 'drupal'),
- '#options' => $options['radios'],
- '#description' => t('!list', array('!list' => theme('item_list', $options['help']))),
- '#prefix' => '<div id="filesystem-radios">',
- '#suffix' => '</div>',
- );
- $form = $form + $options['admin_settings'];
- return $form;
- }
-
- private function _filesystem() {
- $files = array();
- // Lets find our transcoder classes and build our radio options
- // We do this by scanning our transcoders folder
- $form = array('radios' => array(), 'help' => array(), 'admin_settings' => array());
- $path = drupal_get_path('module', 'video') . '/filesystem';
- $files = file_scan_directory($path, '/.*\.inc/');
- // check inside sub modules
- $modules = module_list();
- foreach ($modules as $module) {
- $mobule_files = array();
- $module_path = drupal_get_path('module', $module) . '/filesystem';
- $mobule_files = file_scan_directory($module_path, '/.*\.inc/');
- $files = array_merge($files, $mobule_files);
- }
-
- foreach ($files as $file) {
- if (!module_load_include('inc', 'video', '/filesystem/' . $file->name))
- require_once $file->filename;
- $focus = new $file->name;
- $form['radios'][$focus->get_value()] = $focus->get_name();
- $form['help'][] = $focus->get_help();
- // creating div for each option
- $form['video_' . $focus->get_value() . '_start'] = array(
- 'video_' . $focus->get_value() . '_start' => array(
- '#type' => 'markup',
- '#value' => '<div id="' . $focus->get_value() . '">',
- ),
- );
- $form['video_' . $focus->get_value() . '_end'] = array(
- 'video_' . $focus->get_value() . '_end' => array(
- '#type' => 'markup',
- '#value' => '</div>',
- ),
- );
-
- $form['admin_settings'] = $form['admin_settings'] + $form['video_' . $focus->get_value() . '_start'] + $focus->admin_settings() + $form['video_' . $focus->get_value() . '_end'];
- }
- return $form;
- }
-
- public function admin_settings_validate(&$form, &$form_state) {
- return $this->filesystem->admin_settings_validate($form, $form_state);
- }
-
-}
-
-interface filesystem_interface {
-
- public function save_file($video);
-
- public function prepare_file($video);
-
- public function load_file($video);
-
- public function get_name();
-
- public function get_help();
-
- public function admin_settings();
-
- public function admin_settings_validate($form, &$form_state);
-} \ No newline at end of file
diff --git a/modules/video_ui/video.admin.inc b/modules/video_ui/video.admin.inc
index 51f9a1c..8ab19b3 100644
--- a/modules/video_ui/video.admin.inc
+++ b/modules/video_ui/video.admin.inc
@@ -161,21 +161,4 @@ function video_cron_admin_settings() {
'#description' => t('How many videos do you want to process on each cron run? Either through hook_cron or the video_scheduler.php.'),
);
return system_settings_form($form);
-}
-
-/**
- * File system admin settings
- * @return <type>
- */
-function video_filesystem_admin_settings() {
- $filesystem = new video_filesystem;
- $form = $filesystem->admin_settings();
- return system_settings_form($form);
-}
-
-function video_filesystem_admin_settings_validate($form, &$form_state) {
- // add vallidations by metadata interface
- $filesystem = $form_state['values']['video_filesystem'];
- $filesystem = new video_filesystem($filesystem);
- $filesystem->admin_settings_validate($form, $form_state);
} \ No newline at end of file
diff --git a/modules/video_ui/video.preset.inc b/modules/video_ui/video.preset.inc
index 981370b..42680cd 100644
--- a/modules/video_ui/video.preset.inc
+++ b/modules/video_ui/video.preset.inc
@@ -50,7 +50,8 @@ function video_preset_default_form($form, &$form_state, $preset) {
'#type' => 'select',
'#title' => t('Video output extension'),
'#description' => t('Extension of the output video.'),
- '#options' => $video_extension
+ '#options' => $video_extension,
+ '#default_value' => (!empty($preset['settings']['video_extension'])) ? $preset['settings']['video_extension'] : 'flv'
);
$form['settings']['video']['video_codec'] = array(
'#type' => 'select',
diff --git a/modules/video_ui/video_ui.module b/modules/video_ui/video_ui.module
index d2edb9e..97a9f4a 100644
--- a/modules/video_ui/video_ui.module
+++ b/modules/video_ui/video_ui.module
@@ -61,14 +61,6 @@ function video_ui_menu() {
'type' => MENU_LOCAL_TASK,
'weight' => 3,
);
-
-// $items['admin/structure/video'] = array(
-// 'title' => 'Video Presets',
-// 'file' => 'includes/video.preset.inc',
-// 'description' => 'Manage and configure the presets for Video.',
-// 'page callback' => 'video_presets_overview',
-// 'access arguments' => array('administer video presets')
-// );
$items['admin/config/media/video/presets/all'] = array(
'title' => 'Presets',
'description' => 'Configure your transcoder presets to convert your videos.',
@@ -149,17 +141,6 @@ function video_ui_menu() {
'type' => MENU_LOCAL_TASK,
'weight' => 4,
);
- // Filesystem settings
- $items['admin/config/media/video/filesystem'] = array(
- 'title' => 'Filesystem',
- 'description' => 'Configure your filesystem settings.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('video_filesystem_admin_settings'),
- 'access arguments' => array('administer site configuration'),
- 'file' => 'video.admin.inc',
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 5,
- );
// Cron settings
$items['admin/config/media/video/cron'] = array(
'title' => 'Cron Settings',
diff --git a/transcoders/video_ffmpeg.inc b/transcoders/video_ffmpeg.inc
index 343d896..d1096f0 100644
--- a/transcoders/video_ffmpeg.inc
+++ b/transcoders/video_ffmpeg.inc
@@ -102,7 +102,7 @@ class video_ffmpeg implements transcoder_interface {
// get the paths so tokens will compatible with this
// @todo : add best method to get existing file path and add converted there
$target = str_replace('original', '', drupal_dirname($video->uri));
- $converted = $target . '/converted/' . $video->fid;
+ $converted = $target . 'converted/' . $video->fid;
if (!file_prepare_directory($converted, FILE_CREATE_DIRECTORY)) {
watchdog('transcoder', 'Video conversion failed. Could not create the directory: ' . $converted, array(), WATCHDOG_ERROR);
return false;
@@ -114,16 +114,22 @@ class video_ffmpeg implements transcoder_interface {
$converted_files = array();
foreach ($presets as $name => $preset) {
$settings = $preset['settings'];
+ // override with preset settings
+ if (isset($settings['width']) && isset($settings['height'])) {
+ $video->dimensions = $settings['width'] . 'x' . $settings['height'];
+ }
$converted .= '/' . file_munge_filename(str_replace(' ', '_', pathinfo($original_video_path, PATHINFO_FILENAME)) . '.' . $settings['video_extension'], $settings['video_extension']);
+ //get the actual video file path from the stream wrappers
+ $converted_video_path = drupal_realpath($converted);
$dimensions = $this->dimensions($video);
$dimention = explode('x', $dimensions);
if ($this->params['enable_faststart'] && in_array($settings['video_extension'], array('mov', 'mp4'))) {
- $ffmpeg_output = file_directory_temp() . '/' . basename($converted);
+ $ffmpeg_output = file_directory_temp() . '/' . basename($converted_video_path);
} else {
- $ffmpeg_output = $converted;
+ $ffmpeg_output = $converted_video_path;
}
// Setup our default command to be run.
- $command = strtr($settings['command'], array(
+ $command = strtr($settings['cli_code'], array(
'!cmd_path' => $this->params['cmd_path'],
'!videofile' => '"' . $original_video_path . '"',
'!audiobitrate' => $settings['audio_bitrate'],
@@ -136,12 +142,12 @@ class video_ffmpeg implements transcoder_interface {
$command_output = $this->run_command($command);
- if ($ffmpeg_output != $converted && file_exists($ffmpeg_output)) {
+ if ($ffmpeg_output != $converted_video_path && file_exists($ffmpeg_output)) {
// Because the transcoder_interface doesn't allow the run_command() to include the ability to pass
// the command to be execute so we need to fudge the command to run qt-faststart.
$cmd_path = $this->params['cmd_path'];
$this->params['cmd_path'] = $this->params['faststart_cmd'];
- $command_output .= $this->run_command($ffmpeg_output . ' ' . $converted, $verbose);
+ $command_output .= $this->run_command($ffmpeg_output . ' ' . $converted_video_path, $verbose);
$this->params['cmd_path'] = $cmd_path;
// Delete the temporary output file.
@@ -149,18 +155,18 @@ class video_ffmpeg implements transcoder_interface {
}
//lets check to make sure our file exists, if not error out
- if (!file_exists($converted) || !filesize($converted)) {
- watchdog('video_conversion', 'Video conversion failed for preset %preset. FFMPEG reported the following output: ' . $command_output, array('%orig' => $video->filepath, '%preset' => $name), WATCHDOG_ERROR);
+ if (!file_exists($converted_video_path) || !filesize($converted_video_path)) {
+ watchdog('transcoder', 'Video conversion failed for preset %preset. FFMPEG reported the following output: ' . $command_output, array('%orig' => $video->uri, '%preset' => $name), WATCHDOG_ERROR);
$this->change_status($video->vid, VIDEO_RENDERING_FAILED);
return FALSE;
}
// Setup our converted video object
- $video_info = pathinfo($converted);
+ $video_info = pathinfo($converted_video_path);
//update our converted video
$video->converted = new stdClass();
$video->converted->vid = $video->vid;
$video->converted->filename = $video_info['basename'];
- $video->converted->filepath = $converted;
+ $video->converted->uri = $converted;
$video->converted->filemime = file_get_mimetype($converted);
$video->converted->filesize = filesize($converted);
$video->converted->status = VIDEO_RENDERING_COMPLETE;
@@ -176,7 +182,7 @@ class video_ffmpeg implements transcoder_interface {
'data' => serialize($converted_files)))
->condition('vid', $video->converted->vid, '=')
->execute();
- watchdog('video_conversion', 'Successfully converted %orig to %dest', array('%orig' => $video->filepath, '%dest' => $video->converted->filepath), WATCHDOG_INFO);
+ watchdog('transcoder', 'Successfully converted %orig to %dest', array('%orig' => $video->uri, '%dest' => $video->converted->uri), WATCHDOG_INFO);
return TRUE;
}
@@ -432,10 +438,10 @@ class video_ffmpeg implements transcoder_interface {
$data = unserialize($file->data);
if (!empty($data))
foreach ($data as $value) {
- $extension = pathinfo($value->filepath, PATHINFO_EXTENSION);
- $video->files->{$extension}->filename = pathinfo($value->filepath, PATHINFO_FILENAME) . '.' . $extension;
- $video->files->{$extension}->filepath = $value->filepath;
- $video->files->{$extension}->url = file_create_url($value->filepath);
+ $extension = pathinfo(drupal_realpath($value->uri), PATHINFO_EXTENSION);
+ $video->files->{$extension}->filename = $value->filename;
+ $video->files->{$extension}->uri = $value->uri;
+ $video->files->{$extension}->url = file_create_url($value->uri);
$video->files->{$extension}->extension = $extension;
$video->player = strtolower($extension);
}
@@ -467,7 +473,7 @@ class video_ffmpeg implements transcoder_interface {
public function dimensions($video) {
//lets setup our dimensions. Make sure our aspect ratio matches the dimensions to be used, if not lets add black bars.
- $aspect_ratio = _video_aspect_ratio($video->filepath);
+ $aspect_ratio = _video_aspect_ratio(drupal_realpath($video->uri));
$ratio = $aspect_ratio['ratio'];
$width = $aspect_ratio ['width'];
$height = $aspect_ratio['height'];
diff --git a/video.field.inc b/video.field.inc
index d81294c..8e819d9 100644
--- a/video.field.inc
+++ b/video.field.inc
@@ -128,6 +128,13 @@ function video_field_prepare_view($entity_type, $entities, $field, $instances, $
* Implements hook_field_presave().
*/
function video_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
+ // change the theumbnails if default is checked
+ if (!empty($field['settings']['default_video_thumbnail'])) {
+ foreach ($items as $delta => $item) {
+ if ($item['use_default_video_thumb'])
+ $items[$delta]['thumbanail'] = $field['settings']['default_video_thumbnail']['fid'];
+ }
+ }
file_field_presave($entity_type, $entity, $field, $instance, $langcode, $items);
}
@@ -444,4 +451,19 @@ function video_field_formatter_view($entity_type, $entity, $field, $instance, $l
);
}
return $element;
+}
+
+/**
+ * Element specific validation for video thumbnail value.
+ *
+ */
+function video_thumbnail_validate($element, &$form_state) {
+ $fid = $element['#value'];
+ // Make the file permanent and store it in the form.
+ if (!empty($fid)) {
+ $file = file_load($fid);
+ $file->status |= FILE_STATUS_PERMANENT;
+ $file = file_save($file);
+// $element['#value'] = (array) $file;
+ }
} \ No newline at end of file
diff --git a/video.module b/video.module
index 765ee5b..7f3283d 100644
--- a/video.module
+++ b/video.module
@@ -127,6 +127,7 @@ function video_theme() {
*/
function video_cron() {
+ return;
module_load_include('inc', 'video', 'includes/conversion');
if (variable_get('video_cron', TRUE)) {
$video_conversion = new video_conversion;
@@ -164,7 +165,8 @@ function video_thumb_process(&$element, &$form_state) {
if (!empty($thumbss)) {
$element['thumbanail'] = array(
'#type' => 'radios',
- '#title' => t('Video Thumbnails'),
+ '#title' => t('Video thumbnails'),
+ '#element_validate' => array('video_thumbnail_validate'),
'#options' => $thumbss,
'#default_value' => !empty($file['thumbanail']) ? $file['thumbanail'] : $thumbs[$default_thumb]->fid,
'#weight' => 10,
@@ -179,9 +181,10 @@ function video_thumb_process(&$element, &$form_state) {
$field['settings']['autothumbnail'] == 'manual_upload') {
$element['thumbanail'] = array(
'#title' => t('Video thumbnail'),
+// '#element_validate' => array('video_thumbnail_validate'),
'#type' => 'managed_file',
'#description' => t('The uploaded image will be used as video thumbnail on this video.'),
- '#default_value' => !empty($file['thumbanail']) ? $file['thumbanail'] : NULL,
+ '#default_value' => !empty($file['thumbanail']['fid']) && is_integer($file['thumbanail']['fid']) ? $file['thumbanail']['fid'] : NULL,
'#upload_location' => file_default_scheme() . '://' . variable_get('video_thumb_path', 'videos/thumbnails') . '/' . $file['fid'],
);
}
@@ -419,7 +422,6 @@ function _video_dimensions_options(&$options, $video) {
function _video_aspect_ratio($video) {
//lets get our video dimensions from the file
- module_load_include('inc', 'video', '/includes/transcoder');
$transcoder = new video_transcoder;
$wxh = $transcoder->get_dimensions($video);
$width = $wxh['width'];
@@ -579,9 +581,9 @@ function video_default_field_settings($settings) {
$form['default_video_thumbnail'] = array(
'#title' => t('Default video thumbnail'),
'#type' => 'managed_file',
-// '#element_validate' => array('video_field_default_thumbnail_validate'),
+ '#element_validate' => array('video_field_default_thumbnail_validate'),
'#description' => t('If use default thumbnanil is selected, this image will be shown on display.'),
- '#default_value' => !empty($settings['default_video_thumbnail']) ? $settings['default_video_thumbnail'] : '',
+ '#default_value' => !empty($settings['default_video_thumbnail']['fid']) ? $settings['default_video_thumbnail']['fid'] : '',
'#upload_location' => 'public://videos/thumbnails/default',
'#weight' => 19,
);