aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--css/video.css77
-rw-r--r--includes/conversion.inc18
-rw-r--r--includes/preset.inc11
-rw-r--r--includes/video_helper.inc10
-rw-r--r--transcoders/video_ffmpeg.inc24
-rw-r--r--video.field.inc23
-rw-r--r--video.module20
7 files changed, 73 insertions, 110 deletions
diff --git a/css/video.css b/css/video.css
index 51d59d2..6964312 100644
--- a/css/video.css
+++ b/css/video.css
@@ -1,75 +1,22 @@
-
-.filefield-element .filefield-file-info, .video_thumbnail {
- min-width: 100px;
- min-height: 100px;
-}
-
-.filefield-element .imagefield-preview {
- min-width: 100px;
- min-height: 100px;
-}
-
-.filefield-element .imagefield-text {
- max-width: 40em; /* Reflect the maxlength of the ALT attribute (80 characters). */
-}
-
-.filefield-element .uploadfield-text {
- max-width: 40em;
-}
-
.video_thumbnail {
min-width: 100px;
min-height: 100px;
}
-.uploadfield {
-
-}
-
-.uploadfield-nodelink {
-
-}
-
-.uploadfield-video-thumb {
-
-}
-
-.uploadfield-video-thumb img{
- width : 250px;
-/* min-width: 100px; */
- min-height: 210px;
-
-}
-
-.uploadfield-video-thumb span{
- /* This is the overlay image for use as a play button. */
- background: url(../images/play.png) no-repeat;
-
- /* This is the size of our button. DOES NOT WORK WITH DEFAULT THUMB SIZE! */
- width: 50px;
- height: 112px;
- position : absolute;
- margin : 65px 100px;
-}
-
-.uploadfield-video-thumb span:hover {
- background-position: -50px 0px;
-}
-
.video-width-text {
width:10px;
}
.video-thumb-selection{
-
+
}
.video-thumb-selection .form-item {
-
+
}
.video-thumbnails{
-/* display : block;*/
+ /* display : block;*/
}
.video-thumbnails .form-item{
float:left;
@@ -82,11 +29,11 @@
}
.video-default-thumbnail{
-
+
}
.video-data{
-
+
}
.video_image_teaser {
@@ -115,27 +62,29 @@ br.video_image_clear {
.widget-edit .form-item { white-space: normal !important; }
.admin_flv_player_wrapper { display: none; }
+
/*
- * VIDEO OJBECT FIXES CROSS BROWSER
- */
+* VIDEO OJBECT FIXES CROSS BROWSER
+*/
* html object.video-object {
- display: none;
+ display: none;
}
* html object.video-object/**/ {
- display: inline;
+ display: inline;
}
* html object.video-object {
- display/**/: none;
+ display/**/: none;
}
-
+
div.video-preview {
float: left; /* LTR */
padding: 0 10px 10px 0; /* LTR */
}
div.video-widget-data {
float: left; /* LTR */
+ width: 85%;
}
div.video-widget-data input.text-field {
width: auto;
diff --git a/includes/conversion.inc b/includes/conversion.inc
index ae25245..493532e 100644
--- a/includes/conversion.inc
+++ b/includes/conversion.inc
@@ -5,16 +5,6 @@
* Class file to handle video conversion using ffmpeg and webservices.
*
*/
-defined('VIDEO_RENDERING_PENDING') ||
- define('VIDEO_RENDERING_PENDING', 1);
-defined('VIDEO_RENDERING_INQUEUE') ||
- define('VIDEO_RENDERING_INQUEUE', 2);
-defined('VIDEO_RENDERING_ACTIVE') ||
- define('VIDEO_RENDERING_ACTIVE', 5);
-defined('VIDEO_RENDERING_COMPLETE') ||
- define('VIDEO_RENDERING_COMPLETE', 10);
-defined('VIDEO_RENDERING_FAILED') ||
- define('VIDEO_RENDERING_FAILED', 20);
class video_conversion {
@@ -69,14 +59,18 @@ class video_conversion {
private function render($video) {
if (!is_object($video)) {
- watchdog('video_conversion', 'Video object is not present', array(), WATCHDOG_ERROR);
+ watchdog('transcoder', 'Video object is not present', array(), WATCHDOG_ERROR);
return FALSE;
}
// Make sure this video is pending or do nothing.
if ($video->video_status == VIDEO_RENDERING_PENDING) {
return $this->transcoder->convert_video($video);
+ } else {
+ $status = array(VIDEO_RENDERING_COMPLETE => 'completed', VIDEO_RENDERING_FAILED => 'failed');
+ watchdog('transcoder', 'Video conversion has been !status. You should add video to the queue. Please check the re-queue to enable the video conversion.',
+ array('!status' => $status[$video->video_status]), WATCHDOG_WARNING);
+ return FALSE;
}
- return NULL;
}
/**
diff --git a/includes/preset.inc b/includes/preset.inc
index c2870a5..7709392 100644
--- a/includes/preset.inc
+++ b/includes/preset.inc
@@ -39,7 +39,12 @@ class video_preset {
$preset[$value['name']] = $value['name'] . ' ' . l(t('edit'), ('admin/config/media/video/presets/preset/' . $value['name']));
// $help[] = $value['name'] . ' - ' . $value['description'] . ' ' . l(t('edit'), preset_get_preset_path('video', $value['name']));
}
-
+ $form['video_use_preset_wxh'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Use preset WxH for video conversion.'),
+ '#default_value' => variable_get('video_use_preset_wxh', FALSE),
+ '#description' => t('Override the user selected WxH with the preset values. This is recommend.')
+ );
$form['video_preset'] = array(
'#type' => 'checkboxes',
'#title' => t('Video transcode presets'),
@@ -67,7 +72,9 @@ class video_preset {
$presets = array();
$preset = $this->preset;
foreach ($preset as $preset_name) {
- $presets[$preset_name] = video_get_preset($preset_name);
+ // skip selecting disabled presets 0=>0
+ if (!empty($preset_name))
+ $presets[$preset_name] = video_get_preset($preset_name);
}
return $presets;
}
diff --git a/includes/video_helper.inc b/includes/video_helper.inc
index cd743c7..63d6f61 100644
--- a/includes/video_helper.inc
+++ b/includes/video_helper.inc
@@ -65,16 +65,6 @@ class video_helper {
}
}
// Let othere module to load the video files by referance
- // Lets find out if we have pushed this file to the cdn if enabled.
- // @TODO : add correct filesystem load to this
- $filesystem = variable_get('video_filesystem', 'drupal');
- if ($filesystem != 'drupal' && !module_exists('video_zencoder')) {
- module_load_include('inc', 'video', '/includes/filesystem');
- $filesystem = new video_filesystem();
- $filesystem->load_file($video);
- }
-
-
// Moved to last to recheck incase we changed our extension above.
$video->flash_player = variable_get('video_extension_' . $video->player . '_flash_player', '');
// Return our object
diff --git a/transcoders/video_ffmpeg.inc b/transcoders/video_ffmpeg.inc
index 14f40c5..287dc19 100644
--- a/transcoders/video_ffmpeg.inc
+++ b/transcoders/video_ffmpeg.inc
@@ -102,10 +102,10 @@ 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;
- if (!file_prepare_directory($converted, FILE_CREATE_DIRECTORY)) {
- watchdog('transcoder', 'Video conversion failed. Could not create the directory: ' . $converted, array(), WATCHDOG_ERROR);
- return false;
+ $converted_base_dir = $target . 'converted/' . $video->fid;
+ if (!file_prepare_directory($converted_base_dir, FILE_CREATE_DIRECTORY)) {
+ watchdog('transcoder', 'Video conversion failed. Could not create the directory: ' . $converted_base_dir, array(), WATCHDOG_ERROR);
+ return FALSE;
}
//get the actual video file path from the stream wrappers
$original_video_path = drupal_realpath($video->uri);
@@ -115,10 +115,11 @@ class video_ffmpeg implements transcoder_interface {
foreach ($presets as $name => $preset) {
$settings = $preset['settings'];
// override with preset settings
- if (isset($settings['width']) && isset($settings['height'])) {
+ if (isset($settings['width']) && !empty($settings['width']) && isset($settings['height']) && !empty($settings['height'])
+ && variable_get('video_use_preset_wxh', FALSE)) {
$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']);
+ $converted = $converted_base_dir . '/' . 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);
@@ -294,12 +295,12 @@ class video_ffmpeg implements transcoder_interface {
'#type' => 'fieldset',
'#title' => t('Video Thumbnails'),
'#collapsible' => TRUE,
- '#collapsed' => TRUE,
+ '#collapsed' => FALSE,
);
$form['autothumb']['video_thumb_save_all'] = array(
'#type' => 'checkbox',
- '#title' => t('Save all thumbnails in file_manged table'),
- '#description' => t('Save all auto created thumbnails to the file_managed table.'),
+ '#title' => t('Save all thumbnails in {file_manged} table'),
+ '#description' => t('Save all auto created thumbnails to the {file_managed} table.'),
'#default_value' => variable_get('video_thumb_save_all', TRUE),
);
$form['autothumb']['video_thumb_path'] = array(
@@ -326,7 +327,7 @@ class video_ffmpeg implements transcoder_interface {
'#type' => 'fieldset',
'#title' => t('Video Conversion'),
'#collapsible' => TRUE,
- '#collapsed' => TRUE
+ '#collapsed' => FALSE
);
$form['autoconv']['video_ffmpeg_enable_faststart'] = array(
'#type' => 'checkbox',
@@ -446,10 +447,13 @@ class video_ffmpeg implements transcoder_interface {
$extension = pathinfo(drupal_realpath($value->uri), PATHINFO_EXTENSION);
$video->files->{$extension}->filename = $value->filename;
$video->files->{$extension}->filepath = $value->uri;
+ $video->files->{$extension}->filemime = file_get_mimetype($value->uri);
$video->files->{$extension}->url = file_create_url($value->uri);
$video->files->{$extension}->extension = $extension;
$video->player = strtolower($extension);
}
+ else
+ return FALSE;
}
/**
diff --git a/video.field.inc b/video.field.inc
index a60e3b2..700cf7e 100644
--- a/video.field.inc
+++ b/video.field.inc
@@ -105,6 +105,9 @@ function video_field_instance_settings_form($field, $instance) {
* Implements hook_field_load().
*/
function video_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) {
+ if ($field['settings']['autoconversion'] == 1) {
+ //load the converted video
+ }
file_field_load($entity_type, $entities, $field, $instances, $langcode, $items, $age);
}
@@ -167,14 +170,15 @@ function _video_field_file_autoconversion($entity_type, $entity, $field, $instan
$video_conversion = new video_conversion;
foreach ($items as $delta => $item) {
// skip adding entry if bypass conversion is checked
- if ($item['bypass_autoconversion'] == 1 || variable_get('video_bypass_conversion', FALSE)) {
+ if (isset($item['bypass_autoconversion']) && ($item['bypass_autoconversion'] == 1 || variable_get('video_bypass_conversion', FALSE))) {
// delete the conversion job if any
$video_conversion->delete_job($item);
return;
}
// re queue for video conversion
- if ($item['re_convert_video'] == 1) {
- $video_conversion->change_status($item['fid'], VIDEO_RENDERING_PENDING);
+ if (isset($item['re_convert_video']) && $item['re_convert_video'] == 1) {
+ $video = $video_conversion->load_job($item['fid']);
+ $video_conversion->change_status($video->vid, VIDEO_RENDERING_PENDING);
}
// Lets verify that we haven't added this video already. Multiple validation fails will cause this to be ran more than once
if (!$video = $video_conversion->load_job($item['fid'])) {
@@ -182,11 +186,14 @@ function _video_field_file_autoconversion($entity_type, $entity, $field, $instan
drupal_set_message(t('Something went wrong with your video job creation. Please check your recent log entries for further debugging.'), 'error');
}
// if convert on save is checked
- if ($item['convert_video_on_save'] == 1 || variable_get('video_convert_on_save', FALSE)) {
- if (!$video_conversion->process($item['fid'])) {
- drupal_set_message(t('Something went wrong with your video conversion. Please check your recent log entries for further debugging.'), 'error');
- } else {
- drupal_set_message(t('Successfully converted your video.'));
+ if (isset($item['convert_video_on_save']) && $item['convert_video_on_save'] == 1 || variable_get('video_convert_on_save', FALSE)) {
+ switch ($video_conversion->process($item['fid'])) {
+ case FALSE:
+ drupal_set_message(t('Something went wrong with your video conversion. Please check your recent log entries for further debugging.'), 'error');
+ break;
+ case TRUE;
+ drupal_set_message(t('Successfully converted your video.'));
+ break;
}
}
}
diff --git a/video.module b/video.module
index d9035c1..400398f 100644
--- a/video.module
+++ b/video.module
@@ -5,6 +5,17 @@
* @file video.module
*
*/
+defined('VIDEO_RENDERING_PENDING') ||
+ define('VIDEO_RENDERING_PENDING', 1);
+defined('VIDEO_RENDERING_INQUEUE') ||
+ define('VIDEO_RENDERING_INQUEUE', 2);
+defined('VIDEO_RENDERING_ACTIVE') ||
+ define('VIDEO_RENDERING_ACTIVE', 5);
+defined('VIDEO_RENDERING_COMPLETE') ||
+ define('VIDEO_RENDERING_COMPLETE', 10);
+defined('VIDEO_RENDERING_FAILED') ||
+ define('VIDEO_RENDERING_FAILED', 20);
+
// include the field element
module_load_include('inc', 'video', 'video.field');
module_load_include('inc', 'video', 'video.features');
@@ -366,16 +377,17 @@ function video_widget_element_settings(&$element, &$form_state) {
// only in preview mode and then create thumbnails
if ($field['settings']['autoconversion']) {
- // check if already converted
+ // check if already converted or failed
module_load_include('inc', 'video', '/includes/conversion');
$video_conversion = new video_conversion;
$video = $video_conversion->load_job($file['fid']);
- if (user_access('re convert video') && $video->video_status == VIDEO_RENDERING_COMPLETE) {
+ if (user_access('re convert video') && isset($video->video_status) && ($video->video_status == VIDEO_RENDERING_COMPLETE || $video->video_status == VIDEO_RENDERING_FAILED)) {
+ $status = array(VIDEO_RENDERING_COMPLETE => 'completed', VIDEO_RENDERING_FAILED => 'failed');
$element['re_convert_video'] = array(
'#type' => 'checkbox',
- '#title' => t('Re-queue video for conversion.'),
+ '#title' => t('Video conversion has been <b>' . $status[$video->video_status] . '!</b>. Re-queue video?.'),
'#description' => t('This will re-convert your video to output formats when you save, or scheduling it for cron.'),
- '#attributes' => array('class' => array('video-re-convert')),
+ '#attributes' => array('class' => array('video-re-convert', 'video-' . $video->video_status)),
);
}
if (user_access('bypass conversion video')) {