Thumbnails for Video Files

Looking from some clarity and guidance.

Clarity Part: I know that ImageMagick has the capacity to extract a still image from a video file but it does not seem that Omeka is using this ability to create thumbnails for video files. Am I missing something where the thumbnail for a video is getting created but I just can;t see where it lives in Omeka?

Guidance: If the ability to extract a still image from a video on upload does not exist in Omeka, how complicated is adding this feature to Omeka? Should it be handled at the Omeka core through a change request or could a Plug-in provide this ability.

Long story short, a site I am developing in Omeka is making use of image thumbnails on the browse page but since the majority of the content on site is going to be video, they need to have video thumbnails created and not a generic video icon. Still image thumbnails would work perfectly but I am not sure where the thumbnail Magick is happening to see if this s possible with video.

Again, thanks for all of you help!

Greg

Hi Greg,

In the short run, for Omeka 1.2, we will not be able to implement this feature in the core, however if you want to contribute a patch to the core, we'd be happy to receive one.

I spent some time looking into this, but have not fully determined the best way to implement this feature. You should review the core code that is controlling derivative images (look at application/libraries/Omeka/File/Derivative/Image.php and application/models/File.php)

Look at the isDerivable function of the Omeka_File_Derivative_Image class. It currently prevents non-images from having derivable images because it uses the getimagesize php function. I tried commenting that condition out, and it was able to create derivative images (including thumbnails) for uploaded PDF files attached to items, however the thumbnails did not display on the site using the item_square_thumbnail() helper function. This may be because findWithImages function in models/FileTable.php did not include that file as having an image. You may be able to make it work if the has_derivative_image flag is set to true for the associated File objects.

For a short term solution, I would try to create a plugin to create derivative images using the after_file_upload hook.

I'd really like to be able to do this as well, so please be in touch if you create/find a solution. Thanks!

Just a follow up on this issue. ImageMagick can create thumbnails of video files but only if they are an animated GIF or multi-layered JPG file. The desired solution of having it happen automatically would mean writing a plug-in that hooks into a different thumbnail extraction tool that adds the images under the thumbnail folders in Omeka as needed.

The quick fix we went with is a somewhat manual one. After a video is loaded into Omeka we take a screenshot of the desired thumbnail then add the image to the existing Moving Image item. When this happens, all of the derivative images are created and linked to the item.

Since there are now two files attached to a single item we sniff the item for thumbnails if we need the image and suppress the image display on the browse page to get only the video. There is probably a more efficient way to do this but this meets our immediate needs and project deadline until we can put more resources on writing the video thumbnail plugin.

Greg

Something that has been rattling around my head recently is using (abusing?) the "add custom metadata" field on the admin Item page and using it like WordPress' Custom Field.

So, the following maybe be a different approach or may be more complicated than what gregdemetrick did. For videos, could you add a "thumbnail" field and enter the URL to your custom crafted thumbnail? Hide this field on show.php. Then use an if/else statement inside the loop on browse.php (you'll have to craft a custom function for calling the thumbnail, though this could be tacked on to the code for adding custom audio and other icons that has been on the forum lately).

An example where we pushed this custom field around is for working with "fuzzy" dates. I added a "Date Certainty" field to each of our main item types. Then the cataloger fills out a date certainty "prefix" if needed (e.g. Before, After, Probably, Around) -- only the word goes here, the numerals for the year still go on Dublin Core date field. It's somewhat of a pain in the butt -- maybe a good option for plugin?

Then, on the public side I have a custom function on show.php for displaying my metadata in a specific order that includes concatenating the date certainty field with DC date field seamlessly. So display of date certainty+date = "Before 1900" or "Probably 1951". The benefit of this is that items can be sorted correctly by the numerals of date field (ok, we haven't implemented this yet, but it is on my list). I also implemented this back in the .9 version when the date field was limited to numerals and I wanted some options for adding Sort later on.

So, the following maybe be a different approach or may be more complicated than what gregdemetrick did. For videos, could you add a "thumbnail" field and enter the URL to your custom crafted thumbnail? Hide this field on show.php. Then use an if/else statement inside the loop on browse.php (you'll have to craft a custom function for calling the thumbnail, though this could be tacked on to the code for adding custom audio and other icons that has been on the forum lately).

I tried out this method, but with no avail. I would really like to hear if you have had any luck with this trick, or anything similar. I haven't tried this plugin, but it seems to have a bit of potential: http://wordpress.org/extend/plugins/tags/video-thumbnail-insurance

Greg wrote:
Since there are now two files attached to a single item we sniff the item for thumbnails if we need the image and suppress the image display on the browse page to get only the video. There is probably a more efficient way to do this but this meets our immediate needs and project deadline until we can put more resources on writing the video thumbnail plugin.

I have a similar situation -- lot's of videos -- mostly YouTube embeds.
If I upload an image just for the sake of a thumbnail, then it displays on the item's page and is confusing at best.

How can I "sniff" if a file is "just" a thumbnail and suppress it's display on show.php but show it on browse.php.

We are also using generic images for thumbnails for audio files, and pdfs, and screenshots for websites.

In those instances there would be two files uploaded for the item. For the youtube items the thumbnail is the only file uploaded.

An interesting combination of issues! What I have below is untested, but should point in a possible direction at least.

If the only thing that we had to address were the youtube videos, it would be pretty straightforward. In the theme's items/show.php file, there is usually some code like this that displays all the files:

<!-- The following returns all of the files associated with an item. -->
    <div id="itemfiles" class="element">
        <h3><?php echo __('Files'); ?></h3>
        <div class="element-text"><?php echo display_files_for_item(); ?></div>
    </div>

In the case of thumbnails that you have added for youtube videos, you could just remove that code and the thumbnail won't show up.

But, when it comes to the other cases you mention, that of course wouldn't work because you _do_ want the files you attached to the item. Depending on what you have, one way at it might be to create substitute functions that let you check on how to proceed when displaying the files.

First, you could create a function, my_theme_display_files_for_item (or whatever prefix makes sense to you), and copy the contents of the original function from application/helpers/ItemFunctions.php :

function my_theme_display_files_for_item($options = array(), $wrapperAttributes = array('class'=>'item-file'), $item = null)
{
    if(!$item) {
        $item = get_current_item();
    }

    return display_files($item->Files, $options, $wrapperAttributes);
}

If you are lucky, you might be able to use info about the item itself to decide whether to display files, maybe by using item_has_type.

Otherwise, you might need to loop through the files themselves to check if you want to display it (e.g., by checking the mimetype). In that approach, instead of passing $item->Files to display_files, you'd just loop through that array, and if the file meets the condition, add it to a separate array that you would pass in.

Hope that helps (and makes sense! there's a lot going on here!)