Tag: transcode

YouTube-esq module for Menalto Gallery v3

by Dan on Oct.07, 2010, under Gallery 3, PHP

I’ve been using Gallery2 on my site now for a few years now. I’ve always had issues with it though, due to it’s somewhat overwhelming complexity, the templating system which I really couldn’t even get a grasp of, and based on some framework I really didn’t understand, I got reluctant to attempt to do anything with the code in the way of writing modules for it. That and file permissions issues plagued my gallery and stopped it working on several occasions.

So I read that Gallery3 was almost ready, and installed the RC2 version. It’s much better in the terms of the way it’s built. It’s modules are simpler to write with a somewhat simple ‘hooks’ based system which actually make extending it’s functionality and hooking into the theme’s areas relatively easily.

One of the main things that I’ve always wanted to do is have my videos stored on my Gallery instead of on YouTube. I get more web-visitor stats from the server, Gallery, and Google Analytics – something I don’t get with YouTube. However, G3 doesn’t support this out of the box. So I wrote one. It’s a somewhat basic implementation of what I eventually want it to be. The biggest part of this for me was trying to get to grips with Gallery3′s new framework (based on Kohana). I figured most of it out by copying the basic structures of other modules I’d installed and modifying it for me own needs. A couple of hours and I’d picked it up relatively easily.

You can download it here: Video Transcode for Gallery 3

I probably shouldn’t be doing this, but in the interest of avoiding dead links, I’ve been updating this post during the development of this module as opposed to posting a new post each time there was a new version.

A couple of things you should note however. If you want to upload a video of more than a couple of megabytes, use the ‘Server Add’ module, as the upload will eventually stall/time out/crash as the transcoding process takes a while. You can check the progress of each of the transcoding tasks (one task for each resolution) in the Maintenance tab of the Admin area. If you see a task as ‘Stalled’, it means ffmpeg has either crashed, or that particular installation doesn’t like one (or more) of the parameters in the command sent to ffmpeg for transcoding.

It currently logs a decent amount of data to var/modules/transcode/log/transcode.log. This is the general output of the module behind the scenes. If a problem arises, this is the first place to look. Also, it logs ffmpeg’s output to a separate file (this is for 2 purposes, one so we can see what ffmpeg is doing having been executed from php/apache, and secondly so the module can work out how far into the transcoding process it is). Here, there’s one log file for each transcode/ffmpeg process.

If you can’t figure out why things aren’t working, drop me a line here, my Contact page, or on the Menalto forum here. I don’t expect this to be perfect, and it’s my first contribution to any open source project, so don’t shoot me down too hard :)


Download here: Video Transcode for Gallery 3

Change Log
7th October 2010 :: Version 1 :: Initial release.
8th October 2010 :: Version 2 :: Removed dependency on php5-ffmpeg, refine audio codec selection list, add support for ffprobe to detect input video’s parameters.
10th October 2010 :: Version 3 :: Removed dependency on ffprobe, improved audio codec detection.
25th October 2010 :: Version 5 :: This module actually starts working on servers other than my own!
28th October 2010 :: Version 6 :: Fixed a bug that makes ffmpeg fall over if the input video’s audio sample resolution is not supported by ADPCM. It now fixes the sample rate to one of 11025 kHz, 22050 kHz or 44100 kHz (whichever is the next lower than the input sample rate).
30th October 2010 :: Version 7 :: Fixed issues providing an ffmpeg path and not saving correctly when no audio codecs are in the select list to begin with.
1st November 2010 :: Version 8 :: Bug fixes, thanks to netprince for the patch, and diverselab, jhend60, shecter and mamouneyya for help getting this working.
3rd November 2010 :: Version 9 :: Final stable release. Fixed issues with crashing due to ffmpeg not detecting/recognising the input file’s audio codec.
11th November 2010 :: Version 10 :: Bitrate tweaks and fix to audio bitrate channel detection and calculation.
13th September 2012 : Version 11 : Applied patch to prevent “Alternative Resolutions” banner appearing on photo pages and pages where transcoding has not been carried out (patch provided by Jannik Graversen).
15th September 2012 : Version 12 : Update codebase, cleanup, fix parsing of ffmpeg output to determine codec support. Utilise ffprobe to get details of source video as it provides a JSON interface. Added “Default Resolution” field, to auto-select on the frontend as opposed to the smallest resolution available. Only display “Alternative Resolutions” if 2 or more resolutions are available. Improvement on the back of patch from v11, using item->is_movie as opposed to counting resolutions to determine whether or not to display that area. Tested with ffmpeg version 0.6.5 through 0.11.1.
17th September 2012 : Version 13 : Fix versioning issue in installed, problem preventing save after upgrade or clean install.

Codex page on Gallery’s website: http://codex.gallery2.org/Gallery3:Modules:transcode

20 Comments :, , , , , , , more...


A few highly recommended websites...