Flash Video (FLV) Streaming With Nginx
I was looking forward for this feature for last 3 months! And at last, it is there! Now, nginx works on our streaming servers perfectly and flv streaming will not be Lighttpd’s unique feature anymore.
This post is about how to use new Nginx module http_flv_module introduced in 0.4.7 (but there was a bug in its implementation, that can be fixed with my patch) and made completely perfect in 0.4.8.
First of all, to use new module, you should (re)complile nginx with –with-http_flv_module option:
# ./configure --with-http_flv_module ...SOME-OTHER-OPTS...
Next your action should be activation of flv streaming module for your flv files in nginx.conf:
1 2 3 4 5 6 7 8 9 10 11 12 | ... http { ... server { ... location ~ \.flv$ { flv; } ... } ... } |
This option will instruct nginx to add special “header” information to data stream if user asked for some flv file and passed parameter “?start=XXX”, which means “give me that flv file from byte XXX to the end of file” (this is the idea of flv streaming).
Last your action, if it was not done before, should be conversion of your video files to FLV format and adding meta info to your created flv files. You can read how to do it in my previous post.
As always, I want to ask you, if you like this post, support it on Digg.com
Related posts:
- Using Lighttpd, Mplayer/Mencoder and Flvtool2 to Implement Flash Video Streaming
- Monitoring nginx Server Statistics With rrdtool
- Google Educational Seminars (techtalks) and Saving Google Video to Local Disk
- Nginx With PHP As FastCGI Howto
- Typical Configurations Overview For Nginx HTTP(S) Reverse Proxy/Web Server

26 Responses to this entry
[...] Notice: Read my new article about flash streaming “Flash Video (FLV) Streaming with Nginx” to learn, how to implement streaming server with nginx. [...]
Hi there
when can we get aio enabled on nginx?
thanks
Сделал все, как сказано в статье, но nginx выдает ошибку 404. В чем может быть проблема?
nginx/0.4.12
Самый простой метод – поглядеть в error_log – там точно сказано
Разобрался, спасибо.
Impressive article. But I could not make nginx work with php, ruby etc in my debian 3.1 VPS with debian etch as HN with OpenVZ.
I followed a tutorial at http://concentrationstudios.com/2006/8/26/nginx-and-rimuhosting-a-grand-ol-time but it does not behave like it is stated after executing the php-spin script in the article.
Debian certainly has nginx binary package in their repositories but I am not sure whether they support all the nginx modules and scripting languages.
Here I have noticed wonderful experts in nginx and lighttpd. I wish experts here (particularly Scondrel) could advise me how to proceed?
Thank you! Spaciva bolshoi!
А как реализовать flv-стриминг в nginx вместе с его внутренним редиректом (X-Accel-Redirect)? $request_uri после редиректа уже не содержит первоначального параметра start..
2lhotski: А что мешает передавать этот параметр в редиректе? Скрипт получает его через GET и отдает назад в редиректе вместе с именем файла.
2Scoundrel: Насколько я понял, параметр для X-Accel-Redirect не парсится как URI, а воспринимается как путь к файлу, который приаттачивается еще к пути в root внутри location. и при отсутсвии файла “/path/some.flv?start=XXX” естественно выдает 404.
Может URI можно как то дополнительным заголовком сформировать? или я жестко туплю?
2Scoundrel: о, пардон, нашел
[...] Последнее действие, которое требуется, если вы его еще не сделали, – это конвертация Вашего видео в FLV формат и добавление meta-информации в созданные файлы Стриминг Flash Video при помощи Nginx [...]
Is there any way to secure the streams so that users cannot download the flv directly?
немогу сообразить обязательно указывать file.flv?&start=123
а если без этой переменной то должно отдать файл с 0 байта, правильно я понимаю?
Hi,
how is the performance of nginx? can it support thousands of users at the sametime?
thanks
Itam,
Nginx is famous for it’s blazing performance.
Hello,
how can I do live streaming video with Nginx ? It is possible ?
нашёл небольшой баг в nginx, если flv-директива стоит после защиты от хотлинка, то стриминг нихрена не работает – отдаёт весь файл целиком, если же до хотлинка – то работает.
вот пример правильной конфигурации:
location ~ \.flv$ {
flv;
}
location ~ \.(jpg|jpeg|gif|mpg|mpeg|wmv|avi|flv)$ {
access_log off;
valid_referers none blocked server_names *.site.com/;
if ($invalid_referer) {
return 403;
}
}
YouTubeRobot.com today announces YouTube Robot 2.0, a tool that enables you to download video from YouTube.com onto your PC, convert it to various formats to watch it when you are on the road on mobile devices like mobile phone, iPod, iPhone, Pocket PC, PSP, or Zune
location ~ \.flv$ { – I had a problem with this line of code, it gave me and 404 error, but when removed the space before \.flv everything was ok
What is the advantages using Nginx for Flash Video (FLV) Streaming?
Nginx, um, seems good. I will give it a try. Thank you for your post
Gonna try it too. Thanks for the info!
PSP Downloads at Ultra High Speed! Download Games for PSP and More! Download as much PSP content as you want to your computer and transfer it to your PSP device. It is easy, fast & fun! Personalize your PSP with themes, wallpapers, screensavers, and never buy a game again. Simply download everything for free! http://www.allfreepspdownloads.com
This website was a godsend, and has already saved me so much money; almost $400 dollars already! I, like most users, came here from a search engine a little weary; however, you guys really pulled through with me every step of the way http://allfreepspdownloads.com
What advantages does ngix have for streaming flv content?
Just wondering, what advantages are there for streaming videos using Nginx, I mean does it provide optional features, stress a server CPU and resources less, could be awesome for a video website to use.