5 C'reating Video DirectoriesIn this tutorial I'm assuming that your lighttpd document root for your video web site is /var/www (the default document root for lighttpd on Debian). Of course, we don't want to store the original videos and the FLV videos in the document root (or a subdirectory) to prevent that anyone can download them directly (if he knows the link). Therefore we create a directory for the original videos (e.g. /var/videos/incoming) and a directory for the FLV videos (e.g. /var/videos/flv) outside the document root: mkdir -p /var/videos/incoming You (or your users) can then upload their original videos to /var/videos/incoming (e.g. through FTP or some web interface that you program), and you can then encode the videos to FLV (either manually or through some script), as shown in the next chapter.
6 Encoding Videos To FLVLet's assume we have a video called video.avi in /var/videos/incoming (works for the extensions .mp4 .mov .mpg .3gp .mpeg .wmv as well). We want to convert it to the file video.flv and store it in the directory /var/videos/flv. I want video.flv to have a size of 320x240 pixels with an audio sampling frequency of 44100 Hz and a frame rate of 12 fps. This is how we do it: ffmpeg -i /var/videos/incoming/video.avi -s 320x240 -ar 44100 -r 12 /var/videos/flv/video.flv (For more options, take a look at man ffmpeg ) This can take some time, and the output should look something like this: server1:~# ffmpeg -i /var/videos/incoming/video.avi -s 320x240 -ar 44100 -r 12 /var/videos/flv/video.flv Please make sure that in the Output section, you see two streams, one for video, one for audio. If you see video only, this means that the sound gets lost which means you've probably done something wrong in chapters two and three. After the conversion, we can now add metadata to video.flv with flvtool2: cat /var/videos/flv/video.flv | flvtool2 -U stdin /var/videos/flv/video.flv
7 Configuring LighttpdNow we have to open lighttpd's main configuration file, /etc/lighttpd/lighttpd.conf, and enable the modules mod_secdownload and mod_flv_streaming in it. It is very important that mod_secdownload is listed before mod_flv_streaming in the server.modules stanza. When I did it the other way round, I found that fast-forwarding the video in FlowPlayer didn't work! vi /etc/lighttpd/lighttpd.conf
In the same file, we add also add the following configuration (you can add it right at the end of /etc/lighttpd/lighttpd.conf):
Please replace somesecret with your own secret string (you can choose one). What mod_secdownload does is this: a web application (e.g. a PHP script) can have a link in it of the following form: <uri-prefix>/<token>/<timestamp-in-hex>/<rel-path> e.g. /dl/d8a8cb150f7e5962f6a8443b0b6c6cc2/46c1d9f6/video.flv where <token> is an MD5 of
mod_secdownload will then map this link to the appropriate file in the secdownload.document-root (which is outside the document root of the web site) and allow access to that file for secdownload.timeout seconds. After secdownload.timeout seconds, the link isn't valid anymore, and access is denied. After we have installed FlowPlayer, we will use a PHP script to generate the appropriate video links for mod_secdownload. You can find more information about mod_secdownload here: http://trac.lighttpd.net/trac/wiki/Docs%3AModSecDownload Don't forget to restart lighttpd after your changes to /etc/lighttpd/lighttpd.conf: /etc/init.d/lighttpd restart |
Thursday, August 23, 2007
Build Your Own Video Community With Lighttpd And FlowPlayer (Debian Etch) part 2
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment