diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9bea433 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +.DS_Store diff --git a/includes/admin.form.inc b/includes/admin.form.inc index 60b5fd0..87d92fc 100644 --- a/includes/admin.form.inc +++ b/includes/admin.form.inc @@ -128,6 +128,13 @@ function islandora_video_admin(array $form, array &$form_state) { ), ), ); + // PEAKS derivatives. + $form['derivatives']['islandora_video_make_peaks_locally'] = array( + '#type' => 'checkbox', + '#title' => t('Create Peaks datastream locally'), + '#description' => t('Generate a peaks file for audio waveform display (not yet implemented).'), + '#default_value' => variable_get('islandora_video_make_archive', FALSE), + ); return system_settings_form($form); } diff --git a/includes/derivatives.inc b/includes/derivatives.inc index fb626ca..1d15c98 100644 --- a/includes/derivatives.inc +++ b/includes/derivatives.inc @@ -144,6 +144,27 @@ function islandora_video_create_mkv(AbstractObject $object, $force = FALSE) { } } +/** + * Creates the PEAKS derivative from the given video file. + * + * @param AbstractObject $object + * An AbstractObject representing an object in Fedora. + * @param bool $force + * Whether the derivative generation is being forced. + * + * @return array + * An array describing the outcome of the PEAKS creation. + * + * @see hook_islandora_derivative() + */ +function islandora_video_create_peaks(AbstractObject $object, $force = FALSE) { + // placeholder function, not yet implemented. Needs to generate peaks file in json format using + // "audiowaveform": https://github.com/bbc/audiowaveform + // see https://wavesurfer-js.org/faq/ + // probably needs to be a 2-step process, first extracting the audio and then generating the peaks + return; +} + /** * Create the thumbnail for the given file. * diff --git a/islandora_video.module b/islandora_video.module index 2285042..ca311d9 100644 --- a/islandora_video.module +++ b/islandora_video.module @@ -182,6 +182,17 @@ function islandora_video_islandora_sp_videocmodel_islandora_derivative() { 'file' => drupal_get_path('module', 'islandora_video') . '/includes/derivatives.inc', ); } + if (variable_get('islandora_video_make_peaks_locally', TRUE)) { + $derivatives[] = array( + 'source_dsid' => NULL, + 'destination_dsid' => 'PEAKS', + 'weight' => 1, + 'function' => array( + 'islandora_video_create_peaks', + ), + 'file' => drupal_get_path('module', 'islandora_video') . '/includes/derivatives.inc', + ); + } return $derivatives; } diff --git a/theme/theme.inc b/theme/theme.inc index f6884b5..8feadb2 100644 --- a/theme/theme.inc +++ b/theme/theme.inc @@ -52,6 +52,13 @@ function template_preprocess_islandora_video(array &$variables) { $mime = 'video/mp4'; + if (isset($object['PEAKS'])) { + $peaks_url = url("islandora/object/{$object->id}/datastream/PEAKS", array('absolute' => TRUE)); + } + else { + $peaks_url = null; + } + $video_params = array( 'pid' => $object->id, ); @@ -61,6 +68,7 @@ function template_preprocess_islandora_video(array &$variables) { $video_params += array( 'mime' => $mime, 'url' => $video_url, + 'peaks' => $peaks_url, ); } // Thumbnail. diff --git a/xml/islandora_video_ds_composite_model.xml b/xml/islandora_video_ds_composite_model.xml index e424c35..c47491a 100644 --- a/xml/islandora_video_ds_composite_model.xml +++ b/xml/islandora_video_ds_composite_model.xml @@ -24,21 +24,24 @@
- + - + - + - + - + + + +