| 1 | What is IndyTube? |
|---|
| 2 | ----------------- |
|---|
| 3 | |
|---|
| 4 | This is a very basic script for reencoding arbitrary video files to |
|---|
| 5 | flash video (flv), and then including this video in the browser with a |
|---|
| 6 | flash video player. The exact same approach can be used to embed a |
|---|
| 7 | cortado java player that can play ogg theora files, but the files here |
|---|
| 8 | don't do that yet. The overriding design goal is to make it |
|---|
| 9 | absolutely trivial for the largest number of users to view video |
|---|
| 10 | content, while still making the original files available for download, |
|---|
| 11 | and not compromising privacy and anonymity of uploaders and viewers by |
|---|
| 12 | relying on a commercial service like YouTube or Google Video. |
|---|
| 13 | |
|---|
| 14 | Design: Why not build this into the cms? |
|---|
| 15 | -------------------------------- |
|---|
| 16 | |
|---|
| 17 | Video transcoding, even on good hardware, is a time-intensive task. |
|---|
| 18 | So any CMS that wanted to support embedded video would probably need |
|---|
| 19 | to run the encoding job in an asynchronous process anyway. On systems |
|---|
| 20 | that do support asynchronous production processes, like Mir, you |
|---|
| 21 | probably wouldn't want to put big encoding jobs into the queue anyway, |
|---|
| 22 | because no one wants to wait 20 minutes for a video to finish encoding |
|---|
| 23 | when they need to update the startpage. Running the video encoding in |
|---|
| 24 | a separate process also allows the encoding process to get "nice'd" |
|---|
| 25 | to an appropriate priority so it doesn't bring down your server. |
|---|
| 26 | It also means that it is very easy to graft support for embedded |
|---|
| 27 | video onto any existing cms that stores video in the file system. |
|---|
| 28 | |
|---|
| 29 | This script uses Twisted networking framework, to run every 60 seconds |
|---|
| 30 | or whatever you like, and scan a directory files for new videos to |
|---|
| 31 | encode. |
|---|
| 32 | |
|---|
| 33 | What do I need to run this? |
|---|
| 34 | --------------------------- |
|---|
| 35 | |
|---|
| 36 | * Python 2.4 or higher |
|---|
| 37 | |
|---|
| 38 | * Flowplayer, available from http://flowplayer.sourceforge.net |
|---|
| 39 | |
|---|
| 40 | This provides a nice embedded flash video player, you should |
|---|
| 41 | download a copy and put a copy on your web site. |
|---|
| 42 | |
|---|
| 43 | * Mencoder, the Mplayer video encoder/decoder swiss army knife. |
|---|
| 44 | |
|---|
| 45 | This is better than ffmpeg because it is designed to handle |
|---|
| 46 | any proprietary cruft that your users throw at it. |
|---|
| 47 | Get it from www.mplayerhq.hu, or, for debian packages, from |
|---|
| 48 | www.debian-multimedia.org |
|---|
| 49 | |
|---|
| 50 | * FLVTool2, http://inlet-media.de/flvtool2 |
|---|
| 51 | |
|---|
| 52 | You need to be able to write some metadata to the file so |
|---|
| 53 | users can seek during playback. This ruby program does the |
|---|
| 54 | trick (make sure you've got ruby installed!) |
|---|
| 55 | |
|---|
| 56 | * Cheetah template library for Python. |
|---|
| 57 | |
|---|
| 58 | You can get this from http://www.cheetahtemplate.org/, or just |
|---|
| 59 | 'apt-get install python-cheetah' |
|---|
| 60 | |
|---|
| 61 | * Twisted networking - |
|---|
| 62 | You can get this from http://www.twistedmatrix.com |
|---|
| 63 | or 'apt-get install python-twisted' |
|---|
| 64 | |
|---|
| 65 | * For OggTheora support, you need ffmpeg2theora and Cortado applet |
|---|
| 66 | |
|---|
| 67 | How do I set it up? |
|---|
| 68 | ------------------- |
|---|
| 69 | |
|---|
| 70 | First, you need to open up indytube.py and change the config variables |
|---|
| 71 | to something sensible(TODO SOON: pull out to command line args). Here |
|---|
| 72 | you need to set the paths for your orginal and encoded files, plus |
|---|
| 73 | urls for the resources like the flowplayer files and your splash |
|---|
| 74 | screen image(an Indymedia one is included here if you need one). You |
|---|
| 75 | can also tweak the encoder options(sensible defaults are included for |
|---|
| 76 | small video files and quick encoding with decent quality) and turn off |
|---|
| 77 | encoding altogether. There's logging settings for debugging, and a |
|---|
| 78 | way to specify the maximum number of encoders you'd like to run in |
|---|
| 79 | parallel, and at what priority. |
|---|
| 80 | |
|---|
| 81 | You also might want to customize the include.template, which is used |
|---|
| 82 | to generate a fragment to be included in any page with video. The |
|---|
| 83 | basic idea is that the cms template is tweaked to pull in this |
|---|
| 84 | template, which does nothing if it isn't there, and also to include a |
|---|
| 85 | "waiting for encoder" message, which a bit of javascript in the |
|---|
| 86 | generated include fragment "turns off". |
|---|
| 87 | |
|---|
| 88 | An example, for mir, might make this more clear. What you need to do |
|---|
| 89 | is go into the place in the article template where the link to the |
|---|
| 90 | video file attached to an article happens, and add something like: |
|---|
| 91 | |
|---|
| 92 | <div id="waiting4encoder${media.id}"> |
|---|
| 93 | <i>Waiting for encoder...check back in 10 minutes for flash version.</i> |
|---|
| 94 | </div> |
|---|
| 95 | <!--#include virtual="/media/${media.creationdate.formatted["yyyy/MM"]}/${media.id}.flv.inc" --> |
|---|
| 96 | |
|---|
| 97 | Make sure that the "waiting4encoder" div preceds the include file! |
|---|
| 98 | Notice you can also put something like: |
|---|
| 99 | |
|---|
| 100 | <!--#config errmsg=" " --> |
|---|
| 101 | |
|---|
| 102 | if you want to suppress the [an error occurred while processing this |
|---|
| 103 | directive] stuff that will happen while you're waiting for an encoder. |
|---|
| 104 | |
|---|
| 105 | Then, just set up indytube.py to run every minute or so out of cron. |
|---|
| 106 | If the maximum numbers of encoders are already running, it just |
|---|
| 107 | stops. Otherwise, it will check for video files in the directory |
|---|
| 108 | you've specified, see if they've already been encoded, or if another |
|---|
| 109 | encoder is already handling them, and if not, generate the flv file |
|---|
| 110 | and the include file. And then you've got streaming embedded video. |
|---|
| 111 | |
|---|
| 112 | |
|---|
| 113 | Still Todo: |
|---|
| 114 | ----------- |
|---|
| 115 | |
|---|
| 116 | * Configuration via command-line options |
|---|
| 117 | * Video thumbnail generation (how do you find a non-blank frame automatically?) |
|---|