Making Gallery2 understand ogg and use video tags

One of the nice new features in the fast evolving HTML 5 spec is support for specific video and audio tags, replacing the more generic object and embed tags that have been used in the past. They have many benefits over the object tag such as a well defined JavaScript interface, controls provided by the browser and support for multiple formats for the browser to choose between for display. The current beta version of Firefox 3.1 supports this and includes support for playing the Ogg format with Theora and Vorbis codecs included. Opera has support underway as well and it looks like the latest Safari releases also have it (though it seems broken in some respects).

I’ve been trying to find a suitable video format for putting my fractal animations online for some time. Pretty much whatever format you choose you suffer because some platform or other doesn’t have a plugin for it by default. If all browsers are slowly getting ogg support though then that seems to be the ideal choice, so I have re-encoded all the animations as ogg files. Unfortunately it seems that my media gallery software (Gallery2) doesn’t support Ogg, and of course it doesn’t use the new video tag either. This is the world of open source though, so after a bit of tinkering I have it all working nicely. It can generate thumbnails for the animations using ffmpeg (which is already used for other video formats anyway) and will display the video using the video tag.

At some point I might try to push this upstream to the Gallery2 guys, but I after spending some time on their site and finding nothing helpful like a bug tracker or a way to pass patches to them I’m not sure when I’ll get round to it. Until then here are the rough instructions for applying the patch and some other changes I had to do. I’m sure there is some way to automate it all but for this one off case it wasn’t really worth my time.

  • Apply the patch in your gallery install directory: “patch -p0 <patchfile
  • Run the following sql in the gallery database: “INSERT INTO g2_MimeTypeMap (g_extension, g_mimetype, g_viewable) VALUES ('ogg', 'video/ogg', 1);” (adjust for the table and column prefixes that you use).
  • Deactivate the ffmpeg plugin (if it is enabled), and then activate it (assuming you want thumbnail generation to work).
  • Delete the database cache in the maintenance section of the gallery admin.

Of course this means that now even fewer people can see the animations I guess. So if you want to see them then you’ll just have to try out the latest Firefox betas!

Oh, watch out for old versions of ffmpeg. The default version on my webhost (dreamhost) crashes when attempting to make a thumbnail of an ogg file. A build of the latest version of ffmpeg works though.

7 thoughts on “Making Gallery2 understand ogg and use video tags”

    1. Ian, I’m not sure what you’re suggesting I do with a canvas. Thanks for the link to the tracker though.

  1. You also need to run this queries to get ogg thumbs.
    UPDATE `gallery2`.`g2_PluginParameterMap` SET `g_parameterValue` = ‘video/mp4|video/mpeg|video/quicktime|video/x-flv|video/x-ms-asf|video/x-ms-wmv|video/x-msvideo|video/ogg’ WHERE CONVERT( `g2_PluginParameterMap`.`g_pluginType` USING utf8 ) = ‘module’ AND CONVERT( `g2_PluginParameterMap`.`g_pluginId` USING utf8 ) = ‘thumbpage’ AND `g2_PluginParameterMap`.`g_itemId` =0 AND CONVERT( `g2_PluginParameterMap`.`g_parameterName` USING utf8 ) = ‘movieTypes’ LIMIT 1 ;
    INSERT INTO `gallery2`.`g2_TkPropertyMimeTypeMap` (`g_propertyName` ,`g_toolkitId` ,`g_mimeType` )VALUES (
    ‘dimensions’, ‘Ffmpeg’, ‘video/ogg’);
    INSERT INTO `gallery2`.`g2_TkPropertyMimeTypeMap` (`g_propertyName` ,`g_toolkitId` ,`g_mimeType` )VALUES (‘dimensions-and-duration’, ‘Ffmpeg’, ‘video/ogg’);
    INSERT INTO `gallery2`.`g2_TkOperatnMimeTypeMap` (`g_operationName` ,`g_toolkitId` ,`g_mimeType` ,`g_priority` )VALUES (‘convert-to-image/jpeg’, ‘Ffmpeg’, ‘video/ogg’, ’25’);
    INSERT INTO `gallery2`.`g2_TkOperatnMimeTypeMap` (`g_operationName` ,`g_toolkitId` ,`g_mimeType` ,`g_priority` )VALUES (‘select-offset’, ‘Ffmpeg’, ‘video/ogg’, ’25’);

  2. Sir_Yaro, that isn’t the case, I certainly never did it and it worked fine. But you must disable then re-enable the ffmpeg plugin, I’m pretty sure that that does all of that database updating, possibly you might need to click the test settings button to check it sees video/ogg but that should be all.

  3. It suppose to be:
    “You also need to run this queries after ffmpeg plugin activation to get ogg thumbs works”

  4. Mossop, i did it. Few times in different combinations. As far understand how all this works, re-enable plugin should run this queries automatically. When I checked files types in ‘Apperance/Thumbnails’ mime type ‘video/ogg’ never showed up as linked with Ffmpeg module. Of course I didn’t got any thumbs. After I run this queries thumbs shows up immediately after I uploaded a movie.

Comments are closed.