Permalink
Browse files

added pathing to theora

  • Loading branch information...
1 parent bcf3fb2 commit 5d86c25435e159e03c57c6189c6fab63a8e1097e Alan Stanley committed with jonathangreen Apr 18, 2012
Showing with 102 additions and 29 deletions.
  1. +63 −0 islandora_video.admin.inc
  2. +8 −2 islandora_video_sp.module
  3. +31 −27 video_sp.inc
View
63 islandora_video.admin.inc
@@ -102,6 +102,53 @@ function islandora_video_admin_settings(&$form_state) {
);
}
+
+ //check for ffmpeg2theora
+ $theora_path = isset($form_state['values']['islandora_theora_path']) ? $form_state['values']['islandora_theora_path'] : variable_get('islandora_theora_path', '/usr/local/bin/ffmpeg2theora');
+ $theora_avail = exec("ls $theora_path");
+
+ $theora_confirmation_message = ($theora_avail ? '<img src="' . url('misc/watchdog-ok.png') . '"/>'
+ . t('Theora2ffmepg found at !theora_path', array('!theora_path' => $theora_path)) : '<img src="'
+ . url('misc/watchdog-error.png') . '"/> '
+ . t('Unable to locate Theora2ffmpeg at !theora_path</p>', array('!theora_path' => $theora_path)));
+
+ $theora = isset($form_state['values']['islandora_video_do_theora']) ? $form_state['values']['islandora_video_do_theora'] : variable_get('islandora_video_do_theora', TRUE);
+
+ $form['video_ahah_theora_wrapper'] = array(
+ '#prefix' => '<div id="ivideo-theora-url">',
+ '#suffix' => '</div>',
+ '#type' => 'fieldset',
+ );
+ $form['video_ahah_theora_wrapper']['islandora_video_do_theora'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Create OGG locally?'),
+ '#description' => t('Leave this box checked unless processing of files is done on an external server.'),
+ '#default_value' => $theora,
+ '#ahah' => array(
+ 'path' => 'islandora/video/theora',
+ 'wrapper' => 'ivideo-theora-url',
+ 'effect' => 'fade',
+ 'event' => 'change'),
+ );
+
+ if ($theora) {
+ $form['video_ahah_theora_wrapper']['islandora_theora_path'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Path to Theora executable'),
+ '#description' => t('Path to theora program on your server'),
+ '#default_value' => $theora_path,
+ '#ahah' => array(
+ 'path' => 'islandora/video/theora',
+ 'wrapper' => 'ivideo-theora-url',
+ 'effect' => 'fade',
+ 'event' => 'change'),
+ );
+ $form['video_ahah_theora_wrapper']['infobox'] = array(
+ '#type' => 'item',
+ '#value' => $theora_confirmation_message,
+ );
+ }
+
$form['buttons']['submit'] = array('#type' => 'submit', '#value' => t('Save Configuration'));
$form['buttons']['reset'] = array('#type' => 'submit', '#value' => t('Reset to defaults'));
$form['#submit'][] = 'video_settings_form_submit';
@@ -140,6 +187,22 @@ function update_exif_div() {
}
/**
+ * update exif div
+ */
+function update_theora_div() {
+
+ $form = video_callback_prep();
+ $changed_elements = $form['video_ahah_theora_wrapper'];
+ unset($changed_elements['#prefix'], $changed_elements['#suffix']);
+ $output = theme('status_messages') . drupal_render($changed_elements);
+ drupal_json(array(
+ 'status' => TRUE,
+ 'data' => $output,
+ ));
+}
+
+
+/**
* book callback prep
* @return type
*/
View
10 islandora_video_sp.module
@@ -18,12 +18,18 @@ function islandora_video_sp_menu() {
'file' => 'islandora_video.admin.inc',
'type' => MENU_CALLBACK,
);
- $items['islandora/video/exif'] = array(
+ $items['islandora/video/exif'] = array(
'page callback' => 'update_exif_div',
'access arguments' => array('view fedora collection'),
'file' => 'islandora_video.admin.inc',
'type' => MENU_CALLBACK,
);
+ $items['islandora/video/theora'] = array(
+ 'page callback' => 'update_theora_div',
+ 'access arguments' => array('view fedora collection'),
+ 'file' => 'islandora_video.admin.inc',
+ 'type' => MENU_CALLBACK,
+ );
return $items;
}
@@ -36,7 +42,7 @@ function islandora_video_sp_required_fedora_objects() {
solution_pack_add_form($form_name, $form_xml);
solution_pack_add_form_association('islandora:sp_videoCModel', $form_name);
-
+
View
58 video_sp.inc
@@ -22,41 +22,45 @@ class VideoCreation {
$changed = TRUE;
}
$success = FALSE;
- if (!variable_get('islandora_video_do_ffm', TRUE)) {
- return;
- }
- $path_info = pathinfo($file);
- //makes mp4 file, adds file in ingest list
- $mp4file = str_replace('.' . $path_info['extension'], '_.mp4', $file);
- $command_string = "$this->executable -i $file -f mp4 -vcodec libx264 -vpre normal -acodec libfaac -ab 128k -ac 2 -async 1 $mp4file";
- exec($command_string, $output, $returnValue);
+ if (variable_get('islandora_video_do_ffm', TRUE)) {
- if ($returnValue == '0') {
- $_SESSION['fedora_ingest_files']["MP4"] = $mp4file;
- $success = TRUE;
- }
- //makes mkv file, adds file in ingest list
- $mkvfile = str_replace('.' . $path_info['extension'], '_.mkv', $file);
- $command_string = "$this->executable -i $file -f mp4 $mkvfile";
- exec($command_string, $output, $returnValue);
+ $path_info = pathinfo($file);
- if ($returnValue == '0') {
- $_SESSION['fedora_ingest_files']["MKV"] = $mkvfile;
- $success = TRUE;
- }
+ //makes mp4 file, adds file in ingest list
+ $mp4file = str_replace('.' . $path_info['extension'], '_.mp4', $file);
+ $command_string = "$this->executable -i $file -f mp4 -vcodec libx264 -vpre normal -acodec libfaac -ab 128k -ac 2 -async 1 $mp4file";
+ exec($command_string, $output, $returnValue);
- //makes ogg file, adds file in ingest list
- $oggfile = str_replace('.' . $path_info['extension'], '_.ogg', $file);
- $command_string = "ffmpeg2theora $file -o $oggfile";
- exec($command_string, $output, $returnValue);
+ if ($returnValue == '0') {
+ $_SESSION['fedora_ingest_files']["MP4"] = $mp4file;
+ $success = TRUE;
+ }
+
+ //makes mkv file, adds file in ingest list
+ $mkvfile = str_replace('.' . $path_info['extension'], '_.mkv', $file);
+ $command_string = "$this->executable -i $file -f mp4 $mkvfile";
+ exec($command_string, $output, $returnValue);
- if ($returnValue == '0') {
- $_SESSION['fedora_ingest_files']["OGG"] = $oggfile;
- $success = TRUE;
+ if ($returnValue == '0') {
+ $_SESSION['fedora_ingest_files']["MKV"] = $mkvfile;
+ $success = TRUE;
+ }
}
+ if (variable_get('islandora_video_do_theora', TRUE)) {
+ //makes ogg file, adds file in ingest list
+ $theora = variable_get('islandora_theora_path', '/usr/local/bin/ffmpeg2theora');
+ $oggfile = str_replace('.' . $path_info['extension'], '_.ogg', $file);
+ $command_string = "$theora $file -o $oggfile";
+ exec($command_string, $output, $returnValue);
+
+ if ($returnValue == '0') {
+ $_SESSION['fedora_ingest_files']["OGG"] = $oggfile;
+ $success = TRUE;
+ }
+ }
// restores original filename, allowing succesful comletion of conetnt model rules
if ($changed) {
rename($file, $original);

0 comments on commit 5d86c25

Please sign in to comment.