Difference between revisions of "API:EPrints/Plugin/Convert/Thumbnails"

From EPrints Documentation
Jump to: navigation, search
(Created page with '<!-- Pod2Wiki=_preamble_ This page has been automatically generated from the EPrints 3.2 source. Any wiki changes made between the 'Pod2Wiki=*' and 'Edit below this comment' com…')
 
 
(3 intermediate revisions by 2 users not shown)
Line 6: Line 6:
 
<!-- Pod2Wiki=_private_ --><!-- Pod2Wiki=head_name -->
 
<!-- Pod2Wiki=_private_ --><!-- Pod2Wiki=head_name -->
 
==NAME==
 
==NAME==
EPrints::Plugin::Convert::Thumbnails - audio visual thumbnailing
+
EPrints::Plugin::Convert::Thumbnails - thumbnail-sized versions of audio/video/images
  
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
 
+
The Thumbnail How-to may also be useful: [[How to customise thumbnails]]
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki=head_synopsis -->
 
<!-- Pod2Wiki=head_synopsis -->
 
==SYNOPSIS==
 
==SYNOPSIS==
<pre> use EPrints;</pre>
+
<source lang="perl">use EPrints;
  
<pre>  # enable audio previews
+
# enable audio previews
  $c-&gt;{plugins}-&gt;{'Convert::Thumbnails'}-&gt;{params}-&gt;{audio} = 1;
+
$c->{plugins}->{'Convert::Thumbnails'}->{params}->{audio} = 1;
  # disable video previews
+
# disable video previews
  $c-&gt;{plugins}-&gt;{'Convert::Thumbnails'}-&gt;{params}-&gt;{video} = 0;</pre>
+
$c->{plugins}->{'Convert::Thumbnails'}->{params}->{video} = 0;
  
<pre>  ...</pre>
+
# enable audio_*/video_* previews
 +
$c->{thumbnail_types} = sub {
 +
my( $list, $repo, $doc ) = @_;
  
<pre>  my $plugin = $session-&gt;plugin( "Convert" );
+
push @$list, qw( audio_mp4 audio_ogg video_mp4 video_ogg );
  my %available = $plugin-&gt;can_convert( $doc );
+
};
  $plugin = $available{"thumbnail_video"}-&gt;{plugin};
 
  $new_doc = $plugin-&gt;convert( $doc, "thumbnail_video" );</pre>
 
  
<pre></pre>
+
...
 +
 
 +
my $plugin = $session->plugin( "Convert" );
 +
my %available = $plugin->can_convert( $doc );
 +
$plugin = $available{"thumbnail_video"}->{plugin};
 +
$new_doc = $plugin->convert( $doc, "thumbnail_video" );
 +
 
 +
</source>
  
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
Line 38: Line 45:
 
Conversion of images, videos and audio into preview/thumbnail versions.
 
Conversion of images, videos and audio into preview/thumbnail versions.
  
This plugin wraps the ImageMagick <em>convert</em> and <em>ffmpeg</em> tools.
+
This plugin wraps the ImageMagick ''convert'' and ''ffmpeg'' tools.
  
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
Line 44: Line 51:
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
<!-- Pod2Wiki=head_parameters -->
+
<!-- Pod2Wiki=head_testing_audio_and_video_conversion -->
==PARAMETERS==
+
===Testing Audio and Video Conversion===
These parameters can be set through the '''plugins.pl''' configuration file. You must also configure the '''executables''' locations for <em>convert</em> and <em>ffmpeg</em> in [[API:EPrints/SystemSettings|EPrints::SystemSettings]].
+
When files are uploaded to EPrints a file format identification process occurs. This is based on the <code>EP_TRIGGER_MEDIA_INFO</code> callbacks. A set of callbacks are provided by ''lib/cfg.d/media_info.pl''. To customise these copy the file to your repository's ''cfg.d/'' directory.
 
 
<!-- Edit below this comment -->
 
  
 +
This plugin relies on the <code>media</code> info added by the file format identification. To check this is working export the EPrint as XML and check for a &lt;media&gt; entry in your document:
  
<!-- Pod2Wiki= -->
+
<pre> ./bin/export [archiveid] eprint XML [eprintid]</pre>
<!-- Pod2Wiki=item_convert_formats_ext_mime_type -->
 
===convert_formats = { ext =&gt; mime_type }===
 
  
Define the formats supported for input by the call_convert() method.
+
At any time you can re-run the file format identification by using <code>redo_mime_type</code> in epadmin:
  
<!-- Edit below this comment -->
+
<pre>  ./bin/epadmin redo_mime_type [archiveid] eprint [eprintid] --verbose</pre>
  
 +
If ''ffprobe'' is configured correctly you should see it being called for each document.
  
<!-- Pod2Wiki= -->
+
Finally, to regenerate thumbnails do:
<!-- Pod2Wiki=item_ffmpeg_formats_ext_mime_type -->
 
===ffmpeg_formats = { ext =&gt; mime_type }===
 
  
Define the formats supported for input by the call_ffmpeg() method.
+
<pre>  ./bin/epadmin redo_thumbnails [archiveid] [eprintid] --verbose</pre>
  
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
Line 70: Line 73:
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
<!-- Pod2Wiki=item_sizes_size_w_h -->
+
<!-- Pod2Wiki=head_parameters -->
===sizes = { size =&gt; [$w, $h] }===
+
==PARAMETERS==
 
+
These parameters can be set through the '''plugins.pl''' configuration file. You must also configure the '''executables''' locations for <em>convert</em> and <em>ffmpeg</em> in [[API:EPrints/SystemSettings|EPrints::SystemSettings]].
Define the size of thumbnails that can be generated e.g. "small =&gt; [66,50]". The image dimensions generated may be smaller than those specified if the aspect ratio of the source document is different.
 
 
 
Images are output in 8-bit paletted PNG.
 
 
 
<!-- Edit below this comment -->
 
  
 +
* convert_formats = { ext =&gt; mime_type }
 +
: Define the formats supported for input by the call_convert() method.
  
<!-- Pod2Wiki= -->
+
* ffmpeg_formats = { ext =&gt; mime_type }
<!-- Pod2Wiki=item_video_1 -->
+
: Define the formats supported for input by the call_ffmpeg() method.
===video = 1===
 
  
Enable video previews.
+
* sizes = { size =&gt; [$w, $h] }
 +
: Define the size of thumbnails that can be generated e.g. "small =&gt; [66,50]". The image dimensions generated may be smaller than those specified if the aspect ratio of the source document is different.
  
<!-- Edit below this comment -->
+
: Images are output in 8-bit paletted PNG.
 
 
 
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki=item_audio_1 -->
 
===audio = 1===
 
 
 
Enable audio previews.
 
 
 
<!-- Edit below this comment -->
 
  
 +
* video = 1
 +
: Enable video previews.
  
<!-- Pod2Wiki= -->
+
* audio = 1
<!-- Pod2Wiki=item_video_height_480 -->
+
: Enable audio previews.
===video_height = "480"===
 
  
Video preview vertical lines.
+
* video_height = "480"
 +
: Video preview vertical lines.
  
<!-- Edit below this comment -->
+
* audio_sampling = "44100"
 +
: Audio frequency sampling rate in Hz.
  
 +
* audio_bitrate = "96k"
 +
: Audio bit rate in kb/s
  
<!-- Pod2Wiki= -->
+
* audio_codec = "libfaac"
<!-- Pod2Wiki=item_audio_sampling_44100 -->
+
: <em>ffmpeg</em> compiled-in AAC codec name.
===audio_sampling = "44100"===
 
  
Audio frequency sampling rate in Hz.
+
* frame_rate = "10.00"
 +
: Video frame rate in fps.
  
<!-- Edit below this comment -->
+
* video_codec = "h264"
 +
: <em>ffmpeg</em> compiled-in H.264 codec name (may be libx264 on some platforms).
  
 +
* video_rate = "1500k"
 +
: Video bit rate in kilobits.
  
<!-- Pod2Wiki= -->
+
* call_convert = sub( $plugin, $dst, $doc, $src, $geom, $size )
<!-- Pod2Wiki=item_audio_bitrate_96k -->
+
: See [[API:EPrints/Plugin/Convert/Thumbnails#call_convert|call_convert]].
===audio_bitrate = "96k"===
 
  
Audio bit rate in kb/s
+
* call_ffmpeg = sub( $plugin, $dst, $doc, $src, $geom, $size, $offset )
 
+
: See [[API:EPrints/Plugin/Convert/Thumbnails#call_ffmpeg|call_ffmpeg]].
<!-- Edit below this comment -->
 
 
 
 
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki=item_audio_codec_libfaac -->
 
===audio_codec = "libfaac"===
 
 
 
<em>ffmpeg</em> compiled-in AAC codec name.
 
 
 
<!-- Edit below this comment -->
 
 
 
 
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki=item_frame_rate_10_00 -->
 
===frame_rate = "10.00"===
 
 
 
Video frame rate in fps.
 
 
 
<!-- Edit below this comment -->
 
 
 
 
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki=item_video_codec_h264 -->
 
===video_codec = "h264"===
 
 
 
<em>ffmpeg</em> compiled-in H.264 codec name (may be libx264 on some platforms).
 
 
 
<!-- Edit below this comment -->
 
 
 
 
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki=item_video_rate_1500k -->
 
===video_rate = "1500k"===
 
 
 
Video bit rate in kilobits.
 
 
 
<!-- Edit below this comment -->
 
 
 
 
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki=item_sub -->
 
===call_convert = sub( $plugin, $dst, $doc, $src, $geom, $size )===
 
 
 
See [[API:EPrints/Plugin/Convert/Thumbnails#call_convert|call_convert]].
 
 
 
<!-- Edit below this comment -->
 
 
 
 
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki=item_sub -->
 
===call_ffmpeg = sub( $plugin, $dst, $doc, $src, $geom, $size, $offset )===
 
 
 
See [[API:EPrints/Plugin/Convert/Thumbnails#call_ffmpeg|call_ffmpeg]].
 
  
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
Line 182: Line 127:
 
<!-- Pod2Wiki=head_methods -->
 
<!-- Pod2Wiki=head_methods -->
 
==METHODS==
 
==METHODS==
<!-- Edit below this comment -->
+
<!-- Pod2Wiki=head_can_convert -->
 
 
 
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki=item_can_convert -->
 
 
===can_convert===
 
===can_convert===
  
Line 200: Line 141:
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
<!-- Pod2Wiki=item_convert -->
+
<!-- Pod2Wiki=head_convert -->
 
===convert===
 
===convert===
  
Line 212: Line 153:
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
<!-- Pod2Wiki=item_export -->
+
<!-- Pod2Wiki=head_export -->
 
===export===
 
===export===
  
Line 226: Line 167:
 
<!-- Pod2Wiki=head_utility_methods -->
 
<!-- Pod2Wiki=head_utility_methods -->
 
===Utility Methods===
 
===Utility Methods===
<!-- Edit below this comment -->
+
$ver = $plugin-&gt;convert_version()
 
 
 
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki=item_convert_version -->
 
====convert_version====
 
 
 
<source lang="perl">$ver = $plugin->convert_version()
 
 
 
</source>
 
 
Returns the MAJOR.MINOR version of ImageMagick.
 
Returns the MAJOR.MINOR version of ImageMagick.
  
 
Returns 0.0 if the version can not be determined.
 
Returns 0.0 if the version can not be determined.
  
<!-- Edit below this comment -->
+
$ok = $plugin-&gt;is_video( $doc )
 
 
 
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki=item_is_video -->
 
====is_video====
 
 
 
<source lang="perl">$ok = $plugin->is_video( $doc )
 
 
 
</source>
 
 
Returns true if $doc is a video.
 
Returns true if $doc is a video.
  
<!-- Edit below this comment -->
+
$doc = $plugin-&gt;intermediate( $doc, $src, $geom, $src )
 
 
 
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki=item_intermediate -->
 
====intermediate====
 
 
 
<source lang="perl">$doc = $plugin->intermediate( $doc, $src, $geom, $src )
 
 
 
</source>
 
 
Attempt to find an intermediate document that we can use to convert from (e.g. make a thumbnail from a preview version).
 
Attempt to find an intermediate document that we can use to convert from (e.g. make a thumbnail from a preview version).
  
 
Returns the original $doc if not intermediate is found.
 
Returns the original $doc if not intermediate is found.
  
<!-- Edit below this comment -->
+
$plugin-&gt;call_convert( $dst, $doc, $src, $geom, $size )
 
 
 
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki=item_call_convert -->
 
====call_convert====
 
 
 
<source lang="perl">$plugin->call_convert( $dst, $doc, $src, $geom, $size )
 
 
 
</source>
 
 
Calls the ImageMagick <em>convert</em> tool to convert $doc into a thumbnail image. Writes the image to $dst. $src is the full path to the main file from $doc. The resulting image should not exceed $geom dimensions ([w,h] array ref).
 
Calls the ImageMagick <em>convert</em> tool to convert $doc into a thumbnail image. Writes the image to $dst. $src is the full path to the main file from $doc. The resulting image should not exceed $geom dimensions ([w,h] array ref).
  
Line 282: Line 187:
 
This method can be overridden with the '''call_convert''' parameter.
 
This method can be overridden with the '''call_convert''' parameter.
  
<!-- Edit below this comment -->
+
$plugin-&gt;call_ffmpeg( $dst, $doc, $src, $geom, $size, $offset )
 
 
 
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki=item_call_ffmpeg -->
 
====call_ffmpeg====
 
 
 
<source lang="perl">$plugin->call_ffmpeg( $dst, $doc, $src, $geom, $size, $offset )
 
 
 
</source>
 
 
Uses the <em>ffmpeg</em> tool to do the image conversion of $doc. $dst is the filename to write to, $src is the filename to read from and $geom is the image dimensions to write.
 
Uses the <em>ffmpeg</em> tool to do the image conversion of $doc. $dst is the filename to write to, $src is the filename to read from and $geom is the image dimensions to write.
  
Line 298: Line 194:
 
$offset is the time offset to extract (for '''audio'''/'''video'''). It is an array ref of [HOUR, MINUTE, SECOND, FRAME].
 
$offset is the time offset to extract (for '''audio'''/'''video'''). It is an array ref of [HOUR, MINUTE, SECOND, FRAME].
  
<!-- Edit below this comment -->
+
$plugin-&gt;export_mp3( $dst, $doc, $src, $rate )
 
 
 
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki=item_export_mp3 -->
 
====export_mp3====
 
 
 
<source lang="perl">$plugin->export_mp3( $dst, $doc, $src, $rate )
 
 
 
</source>
 
 
Export $src to $dst in MP3 format at sampling rate $rate.
 
Export $src to $dst in MP3 format at sampling rate $rate.
  
<!-- Edit below this comment -->
+
$plugin-&gt;export_audio( $dst, $doc, $src, $container )
 
 
 
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki=item_export_audio -->
 
====export_audio====
 
 
 
<source lang="perl">$plugin->export_audio( $dst, $doc, $src, $container )
 
 
 
</source>
 
 
Export audio-only $src to $dst in $container format.
 
Export audio-only $src to $dst in $container format.
  
 
Audio is encoded as <em>audio_codec</em>.
 
Audio is encoded as <em>audio_codec</em>.
  
<!-- Edit below this comment -->
+
$plugin-&gt;export_video( $dst, $doc, $src, $container )
 
 
 
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki=item_export_video -->
 
====export_video====
 
 
 
<source lang="perl">$plugin->export_video( $dst, $doc, $src, $container )
 
 
 
</source>
 
 
Export audio and video $src to $dst in $container format with vertical lines $lines maintaining aspect ratio.
 
Export audio and video $src to $dst in $container format with vertical lines $lines maintaining aspect ratio.
  
Line 340: Line 209:
 
Audio is encoded as <em>audio_codec</em>.
 
Audio is encoded as <em>audio_codec</em>.
  
<!-- Edit below this comment -->
+
$plugin-&gt;export_cell( $dir, $doc, $src, $geom, $size, $offset )
 
 
 
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki=item_export_cell -->
 
====export_cell====
 
 
 
<source lang="perl">$plugin->export_cell( $dir, $doc, $src, $geom, $size, $offset )
 
 
 
</source>
 
 
Export $src to $dst in JPG format in dimensions $geom from offset $offset.
 
Export $src to $dst in JPG format in dimensions $geom from offset $offset.
  
<!-- Edit below this comment -->
+
$secs = $plugin-&gt;calculate_offset( $duration, $offset )
 
 
 
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki=item_calculate_offset -->
 
====calculate_offset====
 
 
 
<source lang="perl">$secs = $plugin->calculate_offset( $duration, $offset )
 
 
 
</source>
 
 
Translates a seconds or percentage offset into seconds from the start time. If the resulting time is greater than $duration returns $duration.
 
Translates a seconds or percentage offset into seconds from the start time. If the resulting time is greater than $duration returns $duration.
  

Latest revision as of 09:56, 22 January 2013

EPrints 3 Reference: Directory Structure - Metadata Fields - Repository Configuration - XML Config Files - XML Export Format - EPrints data structure - Core API - Data Objects


API: Core API

Latest Source Code (3.4, 3.3) | Revision Log | Before editing this page please read Pod2Wiki


NAME

EPrints::Plugin::Convert::Thumbnails - thumbnail-sized versions of audio/video/images


The Thumbnail How-to may also be useful: How to customise thumbnails

SYNOPSIS

use EPrints;

# enable audio previews
$c->{plugins}->{'Convert::Thumbnails'}->{params}->{audio} = 1;
# disable video previews
$c->{plugins}->{'Convert::Thumbnails'}->{params}->{video} = 0;

# enable audio_*/video_* previews
$c->{thumbnail_types} = sub {
	my( $list, $repo, $doc ) = @_;

	push @$list, qw( audio_mp4 audio_ogg video_mp4 video_ogg );
};

...

my $plugin = $session->plugin( "Convert" );
my %available = $plugin->can_convert( $doc );
$plugin = $available{"thumbnail_video"}->{plugin};
$new_doc = $plugin->convert( $doc, "thumbnail_video" );


DESCRIPTION

Conversion of images, videos and audio into preview/thumbnail versions.

This plugin wraps the ImageMagick convert and ffmpeg tools.


Testing Audio and Video Conversion

When files are uploaded to EPrints a file format identification process occurs. This is based on the EP_TRIGGER_MEDIA_INFO callbacks. A set of callbacks are provided by lib/cfg.d/media_info.pl. To customise these copy the file to your repository's cfg.d/ directory.

This plugin relies on the media info added by the file format identification. To check this is working export the EPrint as XML and check for a <media> entry in your document:

  ./bin/export [archiveid] eprint XML [eprintid]

At any time you can re-run the file format identification by using redo_mime_type in epadmin:

  ./bin/epadmin redo_mime_type [archiveid] eprint [eprintid] --verbose

If ffprobe is configured correctly you should see it being called for each document.

Finally, to regenerate thumbnails do:

  ./bin/epadmin redo_thumbnails [archiveid] [eprintid] --verbose


PARAMETERS

These parameters can be set through the plugins.pl configuration file. You must also configure the executables locations for convert and ffmpeg in EPrints::SystemSettings.

  • convert_formats = { ext => mime_type }
Define the formats supported for input by the call_convert() method.
  • ffmpeg_formats = { ext => mime_type }
Define the formats supported for input by the call_ffmpeg() method.
  • sizes = { size => [$w, $h] }
Define the size of thumbnails that can be generated e.g. "small => [66,50]". The image dimensions generated may be smaller than those specified if the aspect ratio of the source document is different.
Images are output in 8-bit paletted PNG.
  • video = 1
Enable video previews.
  • audio = 1
Enable audio previews.
  • video_height = "480"
Video preview vertical lines.
  • audio_sampling = "44100"
Audio frequency sampling rate in Hz.
  • audio_bitrate = "96k"
Audio bit rate in kb/s
  • audio_codec = "libfaac"
ffmpeg compiled-in AAC codec name.
  • frame_rate = "10.00"
Video frame rate in fps.
  • video_codec = "h264"
ffmpeg compiled-in H.264 codec name (may be libx264 on some platforms).
  • video_rate = "1500k"
Video bit rate in kilobits.
  • call_convert = sub( $plugin, $dst, $doc, $src, $geom, $size )
See call_convert.
  • call_ffmpeg = sub( $plugin, $dst, $doc, $src, $geom, $size, $offset )
See call_ffmpeg.


METHODS

can_convert

%types = $plugin->can_convert( $doc )

Returns a hash map of types this plugin can convert $doc to.

This may be relatively expensive to do if the plugin has to call an external tool to determine if it can export something.


convert

$new_doc = $plugin->convert( $eprint, $doc, $type )

Request the plugin converts $doc to $type, as returned by can_convert.


export

@filelist = $plugin->export( $dir, $doc, $type )

Request the plugin converts $doc to $type, as returned by can_convert. Outputs the resulting files to $dir and returns their paths (excluding the leading $dir part).


Utility Methods

$ver = $plugin->convert_version()

Returns the MAJOR.MINOR version of ImageMagick.

Returns 0.0 if the version can not be determined.

$ok = $plugin->is_video( $doc )

Returns true if $doc is a video.

$doc = $plugin->intermediate( $doc, $src, $geom, $src )

Attempt to find an intermediate document that we can use to convert from (e.g. make a thumbnail from a preview version).

Returns the original $doc if not intermediate is found.

$plugin->call_convert( $dst, $doc, $src, $geom, $size )

Calls the ImageMagick convert tool to convert $doc into a thumbnail image. Writes the image to $dst. $src is the full path to the main file from $doc. The resulting image should not exceed $geom dimensions ([w,h] array ref).

$size is the thumbnail-defined size (as-in the keys to the sizes parameter).

This method can be overridden with the call_convert parameter.

$plugin->call_ffmpeg( $dst, $doc, $src, $geom, $size, $offset )

Uses the ffmpeg tool to do the image conversion of $doc. $dst is the filename to write to, $src is the filename to read from and $geom is the image dimensions to write.

$size is the thumbnail-defined size (as-in the keys to the sizes parameter or audio or video).

$offset is the time offset to extract (for audio/video). It is an array ref of [HOUR, MINUTE, SECOND, FRAME].

$plugin->export_mp3( $dst, $doc, $src, $rate )

Export $src to $dst in MP3 format at sampling rate $rate.

$plugin->export_audio( $dst, $doc, $src, $container )

Export audio-only $src to $dst in $container format.

Audio is encoded as audio_codec.

$plugin->export_video( $dst, $doc, $src, $container )

Export audio and video $src to $dst in $container format with vertical lines $lines maintaining aspect ratio.

Video is encoded as video_codec.

Audio is encoded as audio_codec.

$plugin->export_cell( $dir, $doc, $src, $geom, $size, $offset )

Export $src to $dst in JPG format in dimensions $geom from offset $offset.

$secs = $plugin->calculate_offset( $duration, $offset )

Translates a seconds or percentage offset into seconds from the start time. If the resulting time is greater than $duration returns $duration.

To specify seconds either use just a number (1234) or append 's' (1234s).

To specify a percentage of $duration append '%' (52%).


SEE ALSO

EPrints::Plugin, EPrints::Plugin::Convert.


AUTHOR

Copyright 2009 Tim Brody <tdb2@ecs.soton.ac.uk>, University of Southampton, UK.

This module is released under the GPLv3 license.


COPYRIGHT

Copyright 2000-2011 University of Southampton.

This file is part of EPrints http://www.eprints.org/.

EPrints is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

EPrints is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with EPrints. If not, see http://www.gnu.org/licenses/.