aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/conversion.inc4
-rw-r--r--includes/transcoder.inc6
-rw-r--r--includes/video_helper.inc10
-rw-r--r--modules/video_ui/video.admin.inc7
-rw-r--r--transcoders/video_ffmpeg.inc112
-rw-r--r--video.field.inc98
-rw-r--r--video.module138
-rw-r--r--video_formatter.inc14
8 files changed, 152 insertions, 237 deletions
diff --git a/includes/conversion.inc b/includes/conversion.inc
index 8b1c165..b9be2b4 100644
--- a/includes/conversion.inc
+++ b/includes/conversion.inc
@@ -89,8 +89,8 @@ class video_conversion {
return $this->transcoder->load_completed_job($video);
}
- public function create_job($video) {
- return $this->transcoder->create_job($video);
+ public function create_job($video, $nid) {
+ return $this->transcoder->create_job($video, $nid);
}
public function update_job($video) {
diff --git a/includes/transcoder.inc b/includes/transcoder.inc
index a57fe91..994ab47 100644
--- a/includes/transcoder.inc
+++ b/includes/transcoder.inc
@@ -167,8 +167,8 @@ class video_transcoder {
return $this->transcoder->get_dimensions($video);
}
- public function create_job($video) {
- return $this->transcoder->create_job($video);
+ public function create_job($video, $nid) {
+ return $this->transcoder->create_job($video, $nid);
}
public function update_job($video) {
@@ -201,7 +201,7 @@ class video_transcoder {
interface transcoder_interface {
- public function create_job($video);
+ public function create_job($video, $nid);
public function update_job($video);
diff --git a/includes/video_helper.inc b/includes/video_helper.inc
index b41f657..a4f2b65 100644
--- a/includes/video_helper.inc
+++ b/includes/video_helper.inc
@@ -54,13 +54,15 @@ class video_helper {
$video->autobuffering = variable_get('video_autobuffering', TRUE);
$video->theora_player = variable_get('video_ogg_player', 'http://theora.org/cortado.jar');
// lets find out if we have transcoded this file and update our paths.
- if (isset($field_settings['autoconversion']) && $field_settings['autoconversion']
- && !$variables['item']['bypass_autoconversion']) {
+ if (isset($field_settings['autoconversion']) && $field_settings['autoconversion']) {
// discard all existing file data
- $video->files = new stdClass();
module_load_include('inc', 'video', '/includes/conversion');
$conversion = new video_conversion;
- $conversion->load_completed_job($video);
+ if ($conversion->load_job($variables['item']['fid'])) {
+ // reset the video files object and add converted videos in to it
+ $video->files = new stdClass();
+ $conversion->load_completed_job($video);
+ }
}
// Let othere module to load the video files by referance
// Lets find out if we have pushed this file to the cdn if enabled.
diff --git a/modules/video_ui/video.admin.inc b/modules/video_ui/video.admin.inc
index 0f55dea..51f9a1c 100644
--- a/modules/video_ui/video.admin.inc
+++ b/modules/video_ui/video.admin.inc
@@ -76,6 +76,13 @@ function video_general_admin_settings() {
'#default_value' => variable_get('video_use_default_thumb', FALSE),
'#description' => t('Override auto thumbnails with default thumbnail.')
);
+ $form['video_publish_on_complete'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Publish when conversion complete'),
+ '#default_value' => variable_get('video_publish_on_complete', TRUE),
+ '#description' => t('Initially un-publish till conversion complete and then
+ publish the node only when conversion complete and successful.')
+ );
return system_settings_form($form);
}
diff --git a/transcoders/video_ffmpeg.inc b/transcoders/video_ffmpeg.inc
index d76efb5..142eaff 100644
--- a/transcoders/video_ffmpeg.inc
+++ b/transcoders/video_ffmpeg.inc
@@ -30,7 +30,7 @@ class video_ffmpeg implements transcoder_interface {
$this->params['command'] = variable_get('video_ffmpeg_helper_auto_cvr_options', $this->command);
$this->params['cmd_path'] = variable_get('video_transcoder_path', $this->ffmpeg);
$this->params['thumb_command'] = variable_get('video_ffmpeg_thumbnailer_options', $this->thumb_command);
- $this->nice = variable_get('video_ffmpeg_nice_enable', false) ? 'nice -n 19' : '';
+ $this->nice = variable_get('video_ffmpeg_nice_enable', false) ? 'nice -n 19 ' : '';
$this->params['videoext'] = variable_get('video_ffmpeg_ext', $this->video_ext);
$this->params['enable_faststart'] = variable_get('video_ffmpeg_enable_faststart', 0);
$this->params['faststart_cmd'] = variable_get('video_ffmpeg_faststart_cmd', '/usr/bin/qt-faststart');
@@ -38,7 +38,7 @@ class video_ffmpeg implements transcoder_interface {
public function run_command($options) {
// $command = $this->nice . ' ' . $this->params['cmd_path'] . ' ' . $options . ' 2>&1';
- $command = $options . ' 2>&1';
+ $command = $this->nice . $options . ' 2>&1';
watchdog('transcoder', 'Executing command: ' . $command, array(), WATCHDOG_DEBUG);
ob_start();
passthru($command, $command_return);
@@ -375,10 +375,25 @@ class video_ffmpeg implements transcoder_interface {
return;
}
- public function create_job($video) {
- return db_query("INSERT INTO {video_files} (fid, status, dimensions) VALUES (%d, %d, '%s')", $video['fid'], VIDEO_RENDERING_PENDING, $video['dimensions']);
+ /**
+ * Interface Implementations
+ * @see sites/all/modules/video/includes/transcoder_interface#create_job()
+ */
+ public function create_job($video, $nid) {
+ return db_insert('video_files')
+ ->fields(array(
+ 'fid' => $video['fid'],
+ 'nid' => $nid,
+ 'status' => VIDEO_RENDERING_PENDING,
+ 'dimensions' => $video['dimensions'],
+ ))
+ ->execute();
}
+ /**
+ * Interface Implementations
+ * @see sites/all/modules/video/includes/transcoder_interface#update_job()
+ */
public function update_job($video) {
if (!$this->load_job($video['fid']))
return;
@@ -386,36 +401,47 @@ class video_ffmpeg implements transcoder_interface {
db_query("UPDATE {video_files} SET nid=%d WHERE fid=%d", $video['nid'], $video['fid']);
}
+ /**
+ * Interface Implementations
+ * @see sites/all/modules/video/includes/transcoder_interface#delete_job()
+ */
public function delete_job($video) {
- if (!$this->load_job($video->fid))
+ if (!$video = $this->load_job($video['fid']))
return;
- //lets get all our videos and unlink them
- $sql = db_query("SELECT data FROM {video_files} WHERE fid=%d", $video->fid);
- //we loop here as future development will include multiple video types (HTML 5)
- while ($row = db_fetch_object($sql)) {
- $data = unserialize($row->data);
- if (empty($data))
- continue;
- foreach ($data as $file) {
+ // converted output values
+ $converted = unserialize($video->data);
+ if (!empty($converted)) {
+ foreach ($converted as $file) {
if (file_exists($file->filepath))
- unlink($file->filepath);
+ @unlink($file->filepath);
}
}
//now delete our rows.
- db_query('DELETE FROM {video_files} WHERE fid = %d', $video->fid);
+ db_delete('video_files')
+ ->condition('fid', $video->fid)
+ ->execute();
}
+ /**
+ * Interface Implementations
+ * @see sites/all/modules/video/includes/transcoder_interface#load_job()
+ */
public function load_job($fid) {
- return;
$job = null;
- $result = db_query('SELECT f.*, vf.vid, vf.nid, vf.dimensions, vf.status as video_status FROM {video_files} vf LEFT JOIN {files} f ON vf.fid = f.fid WHERE f.fid=vf.fid AND f.fid = %d', $fid);
- $job = db_fetch_object($result);
+ $job = db_query("SELECT f.*, vf.vid, vf.nid, vf.dimensions, vf.data, vf.status as video_status
+ FROM {video_files} vf LEFT JOIN {file_managed} f ON vf.fid = f.fid WHERE f.fid=vf.fid AND f.fid = :fid",
+ array(':fid' => $fid))
+ ->fetch();
if (!empty($job))
return $job;
else
return FALSE;
}
+ /**
+ * Interface Implementations
+ * @see sites/all/modules/video/includes/transcoder_interface#load_job_queue()
+ */
public function load_job_queue() {
return;
$total_videos = variable_get('video_ffmpeg_instances', 5);
@@ -424,32 +450,41 @@ class video_ffmpeg implements transcoder_interface {
FROM {video_files} vf LEFT JOIN {files} f ON vf.fid = f.fid
WHERE vf.status = :vstatus AND f.status = :fstatus ORDER BY f.timestamp',
array(':vstatus' => VIDEO_RENDERING_PENDING, ':fstatus' => FILE_STATUS_PERMANENT), 0, $total_videos, array());
-
- while ($row = db_fetch_object($result)) {
+ $job = db_query("SELECT f.*, vf.vid, vf.nid, vf.dimensions, vf.data, vf.status as video_status
+ FROM {video_files} vf LEFT JOIN {file_managed} f ON vf.fid = f.fid WHERE f.fid=vf.fid AND f.fid = :fid",
+ array(':fid' => $fid))
+ ->fetch();
+
+ $query = db_select('file_managed', 'f');
+ $query->join('video_files', 'vf');
+ $query->condition('f.status', FILE_STATUS_PERMANENT, '=')
+ ->condition('vf.status', VIDEO_RENDERING_PENDING, '=')
+ ->fields('f', array('fid', 'uid', 'filename', 'uri', 'status', 'filemime', 'filesize'))
+ ->fields('vf', array('vif', 'fid', 'nid', 'dimension', 'status', 'data'))
+ ->range(0, variable_get('video_ffmpeg_instances', 5));
+ $result = $query->execute();
+ foreach ($result as $row) {
$videos[] = $row;
}
return $videos;
}
/**
- * @todo : replace with the load job method
- * @param <type> $video
- * @return <type>
+ * Interface Implementations
+ * @see sites/all/modules/video/includes/transcoder_interface#load_completed_job()
*/
public function load_completed_job(&$video) {
- $result = db_fetch_object(db_query('SELECT * FROM {video_files} WHERE fid = %d', $video->fid));
- $data = unserialize($result->data);
- if (empty($data))
- return $video;
- 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);
- $video->files->{$extension}->extension = $extension;
- $video->player = strtolower($extension);
- }
- return $video;
+ $file = $this->load_job($video->fid);
+ $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);
+ $video->files->{$extension}->extension = $extension;
+ $video->player = strtolower($extension);
+ }
}
/**
@@ -459,7 +494,10 @@ class video_ffmpeg implements transcoder_interface {
* @param (int) $status
*/
public function change_status($vid, $status) {
- $result = db_query('UPDATE {video_files} SET status = %d WHERE vid = %d ', $status, $vid);
+ db_update('video_files')->fields(array(
+ 'status' => $status,))
+ ->condition('vid', $vid, '=')
+ ->execute();
}
/*
diff --git a/video.field.inc b/video.field.inc
index bb4e33f..0534efc 100644
--- a/video.field.inc
+++ b/video.field.inc
@@ -21,7 +21,7 @@ function video_field_info() {
'preview_video_thumb_style' => 'thumbnail',
),
'instance_settings' => array(
- 'file_extensions' => 'mp4 ogg avi mov wmv flv',
+ 'file_extensions' => 'mp4 ogg avi mov wmv flv ogv webm',
'file_directory' => 'videos/original',
'max_filesize' => '',
'default_dimensions' => '640x350',
@@ -136,6 +136,12 @@ function video_field_presave($entity_type, $entity, $field, $instance, $langcode
*/
function video_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) {
file_field_insert($entity_type, $entity, $field, $instance, $langcode, $items);
+ // Create entry for video conversion if auto converison is enabled
+// if ($field['settings']['autoconversion'] == 1) {
+// foreach ($items as $delta => $item) {
+// video_convert_process($item);
+// }
+// }
}
/**
@@ -143,6 +149,33 @@ function video_field_insert($entity_type, $entity, $field, $instance, $langcode,
*/
function video_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) {
file_field_update($entity_type, $entity, $field, $instance, $langcode, $items);
+ // Create entry for video conversion if auto converison is enabled
+ if ($field['settings']['autoconversion'] == 1) {
+ $nid = $entity->vid;
+ module_load_include('inc', 'video', '/includes/conversion');
+ $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)) {
+ // delete the conversion job if any
+ $video_conversion->delete_job($item);
+ return;
+ }
+ // 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'])) {
+ if (!($video_conversion->create_job($item, $nid)))
+ 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.'));
+ }
+ }
+ }
+ }
}
/**
@@ -182,17 +215,17 @@ function video_field_widget_info() {
'default value' => FIELD_BEHAVIOR_NONE,
),
),
- 'video_ftp' => array(
- 'label' => t('Video FTP'),
- 'field types' => array('video'),
- 'settings' => array(
- 'progress_indicator' => 'throbber',
- ),
- 'behaviors' => array(
- 'multiple values' => FIELD_BEHAVIOR_CUSTOM,
- 'default value' => FIELD_BEHAVIOR_NONE,
- ),
- ),
+// 'video_ftp' => array(
+// 'label' => t('Video FTP'),
+// 'field types' => array('video'),
+// 'settings' => array(
+// 'progress_indicator' => 'throbber',
+// ),
+// 'behaviors' => array(
+// 'multiple values' => FIELD_BEHAVIOR_CUSTOM,
+// 'default value' => FIELD_BEHAVIOR_NONE,
+// ),
+// ),
);
}
@@ -210,7 +243,6 @@ function video_field_widget_settings_form($field, $instance) {
* Implements hook_field_widget_form().
*/
function video_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
-// return;
// Add display_field setting to field because file_field_widget_form() assumes it is set.
$field['settings']['display_field'] = 0;
@@ -218,13 +250,13 @@ function video_field_widget_form(&$form, &$form_state, $field, $instance, $langc
$settings = $instance['settings'];
foreach (element_children($elements) as $delta) {
- // If not using custom extension validation, ensure this is an image.
- $supported_extensions = array('mp4', 'ogg', 'avi', 'mov', 'wmv', 'flv');
+ // If not using custom extension validation, ensure this is an video.
+ $supported_extensions = array_keys(video_video_extensions());
$extensions = isset($elements[$delta]['#upload_validators']['file_validate_extensions'][0]) ? $elements[$delta]['#upload_validators']['file_validate_extensions'][0] : implode(' ', $supported_extensions);
$extensions = array_intersect(explode(' ', $extensions), $supported_extensions);
$elements[$delta]['#upload_validators']['file_validate_extensions'][0] = implode(' ', $extensions);
- // Add all extra functionality provided by the image widget.
+ // Add all extra functionality provided by the video widget.
$elements[$delta]['#process'][] = 'video_field_widget_process';
}
@@ -251,20 +283,7 @@ function video_field_widget_process($element, &$form_state, $form) {
$instance = field_widget_instance($element, $form_state);
$settings = $field['settings'];
$element['#theme'] = 'video_widget';
-// $element['#attached']['css'][] = drupal_get_path('module', 'video') . '/css/video.css';
$element['preview'] = array();
- // preview the video thumbnail
-// if (isset($element['preview']) && $element['#value']['fid'] != 0) {
-// $element['preview']['#value'] = theme('video_widget_preview', $element['#value']);
-// }
- // Add the image preview.
- if ($settings['default_video_thumbnail'] && $element['#value']['fid'] != 0) {
- $default_thumbnail = file_load($settings['default_video_thumbnail']);
-// $element['preview'] = array(
-// '#type' => 'markup',
-// '#markup' => theme('image_style', array('style_name' => $settings['preview_video_thumb_style'], 'path' => $default_thumbnail->uri)),
-// );
- }
// Title is not necessary for each individual field.
if ($field['cardinality'] != 1) {
unset($element['#title']);
@@ -276,18 +295,11 @@ function video_field_widget_process($element, &$form_state, $form) {
case 'video_ftp':
break;
}
- // Create our thumbnails
- video_thumb_process($element, $form_state);
-
-
// Add our extra fields if in preview mode
if (!empty($item['fid'])) {
video_widget_element_settings($element, $form_state);
- }
-
- // Lets use the clicked_button #submit[0] value here instead and see how that works out for now...
- if ($form_state['submitted'] == 1) {
- video_widget_process($element, $form_state);
+ // Create our thumbnails
+ video_thumb_process($element, $form_state);
}
return $element;
}
@@ -311,16 +323,6 @@ function video_field_formatter_info() {
'field types' => array('video'),
'settings' => array('video_style' => '', 'video_link' => ''),
),
- //'video_colorbox' => array(
- // 'label' => t('Video Thumbnail to Colorbox'),
- // 'field types' => array('filefield'),
- // 'description' => t('Displays the video thumbnail and adds colorbox support.'),
- //),
-// 'video_media_js' => array(
-// 'label' => t('Video inject with jMedia'),
-// 'field types' => array('video'),
-// 'description' => t('Displays the video by using jmedia javascript.'),
-// ),
);
return $formatters;
}
diff --git a/video.module b/video.module
index 0a0586c..a2be02a 100644
--- a/video.module
+++ b/video.module
@@ -205,7 +205,7 @@ function video_thumb_process(&$element, &$form_state) {
'#title' => t('Video thumbnail'),
'#type' => 'managed_file',
'#description' => t('The uploaded image will be used as video thumbnail on this video.'),
- '#default_value' => !empty($file['thumbanail']) ? $file['thumbanail'] : FALSE,
+ '#default_value' => !empty($file['thumbanail']) ? $file['thumbanail'] : NULL,
'#upload_location' => file_default_scheme() . '://' . variable_get('video_thumb_path', 'videos/thumbnails') . '/' . $file['fid'],
);
}
@@ -234,70 +234,6 @@ function video_thumb_process(&$element, &$form_state) {
}
/**
- * Adds a video to the video rendering table.
- *
- * If auto converting, it will convert your video to flv right now. We are passing the element by reference
- * just in case we ever want to add more to the element during this process.
- *
- * @param $element
- * Form element to get the video file from.
- */
-function video_convert_process(&$element) {
- $file = $element['#value'];
- // Add default dimensions from our default_value if needed
- if (!isset($file['data']['dimensions'])) {
- $file['data']['dimensions'] = $element['data']['dimensions']['#value'];
- }
- $convert = false;
- //we need to check if this fid has already been added to the database AND that there is in fact a fid
- if (is_array($file) && isset($file['fid']) && !empty($file['fid']) && !isset($file['data']['bypass_autoconversion'])) {
- $fid = $file['fid'];
- //setup our conversion class and check for the fid existence.
- module_load_include('inc', 'video', '/includes/conversion');
- $video_conversion = new video_conversion;
-
- // 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($fid)) {
- // Video has not been added to the queue yet so lets add it.
- $video = array('fid' => $fid, 'dimensions' => $file['data']['dimensions']);
- if (!($video_conversion->create_job($video)))
- drupal_set_message(t('Something went wrong with your video job creation. Please check your recent log entries for further debugging.'), 'error');
- $convert = true;
- //lets queue our node status to unpublished.
- $element['#unpublish'] = true;
- } elseif ($video->video_status != VIDEO_RENDERING_COMPLETE) {
- //lets queue our node status to unpublished.
- $element['#unpublish'] = true;
- }
-
- // Our video should be in the database pending, lets see if we need to convert it now.
- // Check if we are going from unselected to selected or if this is a new video and we have checked the checkbox
- $convert_video_on_save = false;
- $element_data_convert_on_save = '';
- $file_date_convet_on_save = '';
- $convert_on_save = variable_get('video_convert_on_save', FALSE);
- if (isset($element['data']['convert_video_on_save']['#value']))
- $element_data_convert_on_save = $element['data']['convert_video_on_save']['#value'];
- if (isset($file['data']['convert_video_on_save']))
- $file_date_convet_on_save = $file['data']['convert_video_on_save'];
- $convert_video_on_save = $element_data_convert_on_save || $file_date_convet_on_save;
- if (((!isset($element['#default_value']['data']['convert_video_on_save']) || !$element['#default_value']['data']['convert_video_on_save'])
- && $convert_video_on_save) || ($convert && $convert_video_on_save) || $convert_on_save) {
- $return = $video_conversion->process($fid);
- if ($return === FALSE) {
- drupal_set_message(t('Something went wrong with your video conversion. Please check your recent log entries for further debugging.'), 'error');
- } elseif ($return === TRUE) {
- //we are always unpublished until we are converted.
- unset($element['#unpublish']);
- drupal_set_message(t('Successfully converted your video.'));
- }
- } elseif ($convert) {
- drupal_set_message(t('Video submission queued for processing. Please wait: our servers are preparing your video for display.'));
- }
- }
-}
-
-/**
* Implementation of hook_file_delete().
*/
function video_file_delete($file) {
@@ -387,7 +323,7 @@ function video_widget_element_settings(&$element, &$form_state) {
}
// Override our dimensions to the user selected.
if (isset($file['dimensions']) && !empty($file['dimensions'])) {
- $dimensions = $file['data']['dimensions'];
+ $dimensions = $file['dimensions'];
}
// Override our player dimensions to the user selected.
@@ -475,76 +411,6 @@ function video_widget_element_settings(&$element, &$form_state) {
}
}
-/**
- * Video_widget_process for API handlers for any video types.
- * @param <type> $element
- * @param <type> $form_state
- */
-function video_widget_process(&$element, &$form_state) {
- $item = $element['#value'];
- $field = field_widget_field($element, $form_state);
- switch ($form_state['clicked_button']['#submit'][0]) {
- case 'node_form_submit':
- // Auto convert our video file
- if ($field['settings']['autoconversion']) {
- video_convert_process($element);
- //lets set our node status to unpublished if our video is not converted.
- if (isset($element['#unpublish']) && $element['#unpublish']) {
- //unpublish the node
- $form_state['values']['status'] = 0;
- }
- }
-
- // Save manually uploaded thumbs (if they exist) and add them to element
- if (isset($_FILES['files']) && is_array($_FILES['files']['name']))
- if (array_key_exists($field['field_name'] . '_' . $element['#delta'] . '_thumbs', $_FILES['files']['name'])) {
- video_upload_manual_thumb($element);
- }
-
- //
- //queue up the file id to update the node id in the video rendering / cdn tables.
- $form_state['values']['video_id'][] = $item['fid'];
- break;
- case 'node_form_build_preview':
- // preview
- break;
- case 'node_form_delete_submit':
- //moved to hook_file_delete in video module.
- break;
- }
-}
-
-/**
- * Handle saving of manual thumbs
- */
-function video_upload_manual_thumb(&$element) {
-
- $destination = file_default_scheme() . ':/' . 'video_thumbs/' . $element['#value']['fid'];
- if (!field_file_check_directory($destination, FILE_CREATE_DIRECTORY)) {
- form_set_error('video_thumb_upload', t('The thumbnail image could not be uploaded. The destination %destination does not exist or is not writable by the server.', array('%destination' => dirname($destination))));
- return;
- }
- $validators = array(
- 'file_validate_is_image' => array(),
- );
-
- if (!$file = file_save_upload($element['#field_name'] . '_' . $element['#delta'] . '_thumbs', $validators, $destination)) {
- // No upload to save we hope... or file_save_upload() reported an error on its own.
- return;
- }
-
- // Remove old image (if any) & clean up database.
- $old_thumb = $element['data']['video_thumb']['#value'];
- if (!empty($old_thumb)) {
- if (file_delete($old_thumb)) {
- db_query('DELETE FROM {files} WHERE filepath=%d', $old_thumb);
- }
- }
- // Make the file permanent and store it in the form.
- file_set_status($file, FILE_STATUS_PERMANENT);
- $element['data']['video_thumb']['#value'] = $file->filepath;
-}
-
/*
* Function updates our options list to show matching aspect ratios and if we have a matching resolution.
*
diff --git a/video_formatter.inc b/video_formatter.inc
index 1ea9498..0be14f8 100644
--- a/video_formatter.inc
+++ b/video_formatter.inc
@@ -1,6 +1,5 @@
<?php
-
/**
* @file
* Video formatter hooks and callbacks.
@@ -15,14 +14,15 @@ function theme_video($variables) {
$field_settings = $variables['field']['settings'];
$instance_settings = $variables['instance']['settings'];
// Only needs to be ran if they are converting videos
- if (isset($field_settings['autoconversion']) && $field_settings['autoconversion'] && !$variables['item']['bypass_autoconversion']) {
+ if (isset($field_settings['autoconversion']) && $field_settings['autoconversion']) {
module_load_include('inc', 'video', '/includes/conversion');
$conversion = new video_conversion;
- $video = $conversion->load_job($variables['item']['fid']);
- if ($video->video_status == VIDEO_RENDERING_ACTIVE || $video->video_status == VIDEO_RENDERING_PENDING) {
- return theme('video_inprogress');
- } else if ($video->video_status == VIDEO_RENDERING_FAILED) {
- return theme('video_encoding_failed');
+ if ($video = $conversion->load_job($variables['item']['fid'])) {
+ if ($video->video_status == VIDEO_RENDERING_ACTIVE || $video->video_status == VIDEO_RENDERING_PENDING) {
+ return theme('video_inprogress');
+ } else if ($video->video_status == VIDEO_RENDERING_FAILED) {
+ return theme('video_encoding_failed');
+ }
}
}
return video_get_player($variables);