Sun 8 Oct 2006
Using Lighttpd, Mplayer/Mencoder and Flvtool2 to Implement Flash Video Streaming
Posted by Scoundrel under Uncategorized ·
It will be really short post about using set of free tools to implement fully functional flash video streaming server. So, what we are going to get at the end of our setup? We are going to get some type of completely free streaming support that is available with Macromedia’s non-free Flash Communication Server (Flash Media Server) (FCS).
First our step as in any video streaming technology will be to prepare some videos for streaming by converting them to specific video format called “Flash Video” (flv) and adding some meta-information there to make stream rewind posible. There lots of small articles in Internet, that saying “just use ffmpeg tool and everything will be fine”, but I should say “no” to these articles authors. Ffmpeg sucks because it supports only small subset of input video formats and we don’t want to do any transcoding of original video to some video formats that ffmpeg can handle (it takes lots of resources, etc). So, my choice for video transcoding is really cool free software called mplayer, that has converting utility mencoder and can handle almost any original format and convert video file to flv format very quickly.
First of all you will need to get mplayer sources from mplayer we site and compile them. I will not describe how to do it because there are lots of articles about this process, but I want to get your attention to simple fact: Try to minimize set of disabled video codecs in compile time by installing all required libraries from your distribution repositories or from sources, because more codecs you will have, more videos you will be able to handle”.
When you’ve installed your mplayer/mencoder tools, you will need to install Ruby language interpreter to be able to run flvtool2 software. Please, ensure, that you have 1.8.4+ version of Ruby.
Next step is to install flvtool2 - tool, that allows us to inject meta-information to video files to make possible video stream rewinds in flash players. You can get it from its home page, but I would suggest you to install this software from SVN repository as described on its home page.
Small notice: current version of flvtool2 has really annoying bug, that prevents it from working with mencoder generated flv files. When you are trying to use it, you’ll get something like this:
To solve this problem you can go to lib/flv/amf_string_buffer.rb file in flvtool2 source tree and change line 163 from
write [(time.to_i * 1000.0)].pack(’G')
to
write [(time.to_f * 1000.0)].pack(’G')
I want to say BIG THANKS to Dmytro Steflyuk for this fix.
So, as for now you are ready to convert your movies from any video format to flv. You can use following set of command to produce file for streaming:
This set of commands will convert orig_file.ext
file to dest_file.flv and will add meta flash information there.
Last thing you should do is to get Lighttpd web server from their site and install it. Then, enable flv-streaming module in its config and you’ll be able to use any flash player, that understands flash streaming idea to create your own Youtube and to get your our own billion of US dollars.
And to thank author of this article, you can simply support it on digg.com.
Notice: Read my new article about flash streaming “Flash Video (FLV) Streaming with Nginx” to learn, how to implement streaming server with nginx.
- Russian Feed Has Been Fixed
- Flash Video (FLV) Streaming With Nginx
- HAProxy - The Reliable, High Performance TCP/HTTP Load Balancer
- SOS!
- High-Performance Ruby On Rails Setups Test: mongrel vs lighttpd vs nginx
2006-10-08 at 8.35 am
[...] Want to say sorry to all my Russian language readers because my Russian Feed has been broken for last week or so after hoster changes. As for now feed works fine and you can read my last post in your native language! [...]
2006-10-08 at 10.55 am
[...] current version of flvtool2 has really annoying bug, that prevents it from working with mencoder generated flv files [...]
Small addition: with ffmpeg you have the same problem
2006-10-08 at 3.32 pm
[...] Using Lighttpd, Mplayer/Mencoder and Flvtool2 to Implement Flash Video Streaming So, what we are going to get at the end of our setup? We are going to get some type of completely free streaming support that is available with Macromedia’s non-free Flash Communication Server (Flash Media Server) (FCS). [...]
2006-10-08 at 5.39 pm
Or… you could run a Red5 server - http://osflash.org/red5
2006-10-08 at 11.48 pm
[...] Here’s a guide on how to use Lighttpd and a few tools to create a video streaming server. Did this guy miss the memo on Red5? Ah well. Posted in Uncategorized | [...]
2006-10-09 at 5.32 am
[...] read more | digg story [...]
2006-10-09 at 6.31 am
Добрый день!
Хочу опубликовать вашу статью на сайте. Допустимо ли это?
2006-10-09 at 7.30 am
Nice Article. I think even some websites provides them like templates (they even include hosting). Look at http://www.alstrasoft.com/.
2006-10-09 at 8.18 am
[...] Homo-Adminus Blog » Using Lighttpd, Mplayer/Mencoder and Flvtool2 to Implement Flash Video Streaming (tags: flash video streaming howto linux lighttpd youtube web2.0 web videos) Posted by xtra Filed in [...]
2006-10-09 at 8.43 am
“..Ffmpeg sucks..”
Mplayer/Mencoder relies on ffmpeg to do much of the encoding… - it’s included with the package.
2006-10-09 at 9.17 am
[...] Homo-Adminus Blog » Using Lighttpd, Mplayer/Mencoder and Flvtool2 to Implement Flash Video Streaming (tags: server video flash) [...]
2006-10-09 at 1.11 pm
[...] Das Homo Adminus Blog beschreibt, wie man mit Opensource-Mitteln eben diesen Service aufsetzen kann. [...]
2006-10-09 at 1.23 pm
[...] A guide to setting up a flash video streaming server. http://http://blog.kovyrin.net/2006/10/08/lighttpd-memcoder-flvtool-for-streaming/ [...]
2006-10-09 at 4.20 pm
[...] Hier ist ein technischer Artikel, der beschreibt, wie man einen Flash Video Streaming Server aufsetzt - gewissermassen als freie Alternative zum Flash Media Server. [...]
2006-10-09 at 6.34 pm
[...] Article about how to create your own video sharing service with flash video streaming using only open-source tools.read more | digg story [...]
2006-10-09 at 6.56 pm
[...] Article about how to create your own video sharing service with flash video streaming using only open-source tools.read more | digg story [...]
2006-10-09 at 8.59 pm
[...] Como está caliente el tema de YouTube, aquí va un tutorial de cómo crear tu propio servidor de streaming de video, y así poder ganar tu propio billón y medio de dólares (artículo original, en Inglés). Lo primero que hay que tener en cuenta es que se necesitará el Flash Communication Server (Flash Media Server) (que no es gratuito), así como un lenguaje enfocado a la Web, es este caso usaremos Ruby. También se necesitarán códecs para convertir los videos a formato Flash Video (.flv) que es el formato que se usará para el streaming. Se usa este tipo de formato ya que se pueden agregar metadatos que permiten habilitar la función de Pausa/Play/Avanzar/Retroceder durante la reproducción en la página Web. [...]
2006-10-09 at 10.38 pm
Hey, looks like someone stole your blog entry without giving any credit:
http : // www . zoji . com / kao / blogs / 75691
2006-10-10 at 4.53 am
2madkarma: thanks. will write an email to him.
2006-10-10 at 5.07 am
My humble apologizes. It has been fixed.
2006-10-10 at 5.28 am
2Kermee: Great thanks!
2006-10-10 at 7.25 am
[...] Hoy la Costa Oeste anoche anochecia agitada, Google decidia comprar youtube, mostrando un cambio de politica (en lugar de desarrolar buenos productos o adquirir productos novedosos para incorporarlos, compran trafico puro y duro). Mark Cuban llamaba gilipollas a Sergei y Larry y seguro que tontos no son. Muchas de las personas que mas quiero y admiro curran en Google ahora mismo y se alli no dejan entrar a tontos precisamente. Por si acaso, lo lo primero que pense es que me iba a pillar el youtube-dl (un scriptito en python para bajar videos de youtube) y bajarme todo lo que pudiera, porque se acabo lo que se daba. Youtube es un coladero de infracciones de copyright, que una empresa pequegna (de las de cara a cruz y que sea lo que dios diga) puede permitirse con tal de crecer en trafico, pero para un gigante como Google significa denuncias de competidores como Sony, cuyos abogados hoy fijo que no duermen. La empresa que una vez mas nos sorprendia con su tecnologia cambia y madura y con su madurez manda la industria a al agno 99, a comprar trafico y dinero rapido, que es para lo que estan las empresas. En el metro escuche a dos que decian que lo han hecho para joder a Yahoo y Flickr, quien sabe, lo interesante es que nuestra querida industria se nos vuelve gilipollas de nuevo y eso significa dos cosas: la primera es que compraran cualquier mierda con tal de que haya usuarios y la segunda es que muchisima gente sin idea volvera a forrarse, asi que habra que prepararse por si nos toca. Youtube no es tecnologia, son muchas maquinas y mucha pasta de ancho de banda, con una minima planificacion para que la cosa escale y no se desborde (basicamente tener los videos replicados un minimo de tres veces (un maximo relativo a la demanda del video) y un buen balanceador de carga. Lo siguiente es una traduccion por pedacitos de un articulo que encontre en del.icio.us y que esta [aqui] y que comenta como con dos o tres escriptitos en unix, nos podemos hacer un servicio como youtube, para ti y para tus amigos, sin censura y sin aparecer en los logs de nadie. La manera mas facil de montarse eso, y que puede ser como esta montado youtube, es bajarse el servidor flash de la misma macromedia, pero con lighttpd (una especie de apache ligero y modular) y mplayer se puede conseguir el mismo efecto. [...]
2006-10-10 at 11.24 am
[...] Article about how to create your own video sharing service with flash video streaming using only open-source tools.read more | digg story [...]
2006-10-10 at 12.46 pm
[...] Link [...]
2006-10-10 at 7.40 pm
[...] Homo-Adminus Blog » Using Lighttpd, Mplayer/Mencoder and Flvtool2 to Implement Flash Video Streaming Using Lighttpd, Mplayer/Mencoder and Flvtool2 to Implement Flash Video Streaming (tags: opensource reference tools media development) [...]
2006-10-10 at 11.24 pm
[...] Homo-Adminus Blog » Using Lighttpd, Mplayer/Mencoder and Flvtool2 to Implement Flash Video Streaming Free Flash Video Streaming (tags: linux lighttpd flash video streaming howto videos mplayer FLV) [...]
2006-10-11 at 12.33 am
[...] Using Lighttpd, Mplayer/Mencoder and Flvtool2 to Implement Flash Video Streaming (tags: sysadmin lighttpd multimedia ruby web freebsd) [...]
2006-10-11 at 7.16 pm
[...] Article about how to create your own video sharing service with flash video streaming using only open-source tools.read more | digg story Related Articles: Fund That Lost Billions Moves to Shut DownThe fund has lost $6.4 billion, according to the letter, which said assets were down 65 to 70 percent for…Research Analyst: YouTube Headed for a Big CrashYouTube has grown dramatically over the last couple of years by providing users the ability to post and share videos…Program Yourself… Trippy Video On YoutubeYou probably won’t regret seeing this.read more | digg story…Billionaires only: The 400 Richest AmericansA nine-figure fortune won’t get you much mention these days, at least not here. This year, for the first time,…Effects of Youtube, Myspace, and the new mediaAs people post content on Youtube, and new shows and novel forms of content pop-up around the Internet, and everyone… [...]
2006-10-14 at 11.00 pm
[...] 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. [...]
2006-10-14 at 11.22 pm
Notice: Read my new article about flash streaming “Flash Video (FLV) Streaming with Nginx” to learn, how to implement streaming server with nginx.
2006-10-16 at 7.25 pm
[...] Homo-Adminus Blog » Using Lighttpd, Mplayer/Mencoder and Flvtool2 to Implement Flash Video Streaming (tags: kovyrin blog lighttpd memcoder flvtool streaming flash homoAdminus) [...]
2006-10-18 at 11.55 pm
[...] Il secondo, sempre in inglese, spiega come creare il proprio personalissimo portale per lo streaming video, in poche parole un piccolo youtube. [...]
2006-10-19 at 9.33 pm
[...] Pues mi buscador me dice que mire en Using Lighttpd, Mplayer/Mencoder and Flvtool2 to Implement Flash Video Streaming y allí me indican sustituya en /opt/lib/site_ruby/1.8/flv/amf_string_buffer.rb la línea 163 : [...]
2006-10-22 at 8.47 pm
You probably didn’t understand how mod_flv_streaming works: It requires a start-parameter in the url and therefore won’t work with (most) flv players out there. See the docs at: http://jan.kneschke.de/projects/flv-streaming/
2006-10-22 at 9.34 pm
I completely understand how it works because I’ve used it on our streaming servers before nginx got same feature.
2006-10-23 at 2.42 pm
[...] 十大javascript开发库 web应用服务 如何做一个类似youtube的网站 [...]
2006-10-31 at 12.07 pm
Огромное спасибо за статью
Обязательно использую
2006-11-02 at 7.37 am
[...] Using Lighttpd, Mplayer/Mencoder and Flvtool2 to Implement Flash Video Streaming Some type of completely free streaming support that is available with Macromedia’s non-free Flash Communication Server (Flash Media Server) (FCS) (categories: video streaming lighttpd flash administration webdev ) [...]
2006-11-04 at 5.37 pm
[...] - Using Lighttpd, Mplayer/Mencoder and Flvtool2 to Implement Flash Video Streaming [...]
2006-11-06 at 7.57 pm
Small detail in comparison, but what’s the best way to get frame grabs of the videos, like YouTube has as a single-image preview?
2006-11-06 at 9.13 pm
2Ben: I’m working on post about thumbs ripping now. Gonna finish it this week.
2006-11-07 at 11.01 pm
2Scoundrel: Excellent! Looking forward to instructions on doing thumbnail ripping! Thanks!
2006-11-09 at 9.56 am
[...] permalink Dazu solltest du aber auch etwas hier im Forum finden.. Naja ich umschreibe dein Problem mal: YouTube! Soetwas mchtest du doch anbieten, oder seh ich das falsch? Dazu kann ich dir folgende Links empfehlen: Flashcomguru.com - The Flash Video Resource: ‘Streaming’ flv video via PHP, take two Homo-Adminus Blog Using Lighttpd, Mplayer/Mencoder and Flvtool2 to Implement Flash Video Streaming [...]
2006-11-17 at 6.08 pm
When I run the mencoder command, I get this error:
CAN’T GET SPECIFIED FORMAT
Cannot initialize muxer.
Exiting…
Any ideas? Mplayer can play fli files fine…
Thanks for the help.
2006-11-25 at 12.31 am
Can this solution be utilized in a shared hosting environment. For example, could I install and run the mplayer and mencoder on a shared hosting site with GoDaddy. The server is Red Hat Linux with Apache.
Any advice would be greatly appreciated.
Thanks!
2006-12-08 at 2.56 pm
[...] Link dump Using Lighttpd, Mplayer/Mencoder and Flvtool2 to Implement Flash Video Streaming :: Homo-Adminus Blog by Alexey Kovyrin Video Blogging using Django and Flash(tm) Video (FLV) DRM - Daniel’s Random Mutterings digg - How to create your own Youtube and get your own billion Eh some i found. I looked for Rails version since I am versed n Rails now instead of python but if you have any leads they would be much appreciated. [...]
2007-01-17 at 2.06 pm
Can i apply this solution for live streaming? (input from a webcam for example)
2007-02-04 at 11.19 am
>любой flash player, понимающий идею стриминга >видео
Например? С поддержкой конструкции ?start=
2007-02-04 at 5.49 pm
2alex: да. именно. он должен читать метаинфо в самом начале и потом при переходах по видео (перематывании) делать ?start=XXX на позицию, указанную в метаинфо рядом с номером ближайшего кейфрейма.
2007-02-04 at 6.34 pm
Да это я понял. Есть уже существующие и работающие реализации - желательно на флэше? Пробовал http://www.flashcomguru.com/index.cfm/2005/11/2/Streaming-flv-video-via-PHP-take-two . При перемотке не обрывает старые закачки. 10 раз перемотаю - имею 11 потоков для одного файла. Ещё раз 6-7 перемотаю - плеер повиснет.
2007-02-04 at 7.21 pm
2alex: Мы писали сами… Наш флеш-девелопер за день наколбасил хотя до этого ваще не видел флеш-фидео. Потому я уверен, что не сильно сложно. Хотя, может, есть и готовое.
2007-02-21 at 2.47 am
Спасибо за пост. mplayer forever.
Достойной заменой может послужить Yamdi, делающая то же самое в контексте задачи и работающая в на порядки быстрее.
Но flvtool2 в силу свой чистой скриптовости имхо жутко тормозная штука и на больших роликах массовую конвертацию делает тяжким трудом
2007-02-21 at 3.35 am
2lhotski: Wow! Great thanks really useful thing!
2007-02-24 at 4.06 pm
[...] If you don’t want to upload your video at Youtube[1] and if you don’t want to set up a streaming server[2] here are some instructions mainly from Netzspielwiese[3] First convert you video with Riva encoder[4] to Flash format, then install the Wordtube[5] plugin and insert some cryptic code in your blog and your video will look like this one. [...]
2007-03-21 at 10.49 am
Здравствуйте! Спасибо за информацию! Есть вопрос - какая конфигурация сервера подойдёт для создания работоспособного сайта с видеоконтентом (на начальной стадии)?
Спасибо.
2007-03-26 at 7.57 am
[...] If you don’t want to upload your video at Youtube[1] and if you don’t want to set up a streaming server[2] here are some instructions mainly from Netzspielwiese[3] for an alternative. [...]
2007-03-29 at 11.51 am
[...] Использование lighttpd, Mplayer/Mencoder и Flvtool2 для реализации потоковой раздачи Flash Video [...]
2007-03-29 at 12.00 pm
[...] Использование lighttpd, Mplayer/Mencoder и Flvtool2 для реализации потоковой раздачи Flash Video [...]
2007-04-04 at 8.34 am
[...] I started from this blog entry. But as I’m using ubuntu dapper, I have the nice debian apt tool [...]
2007-05-27 at 4.33 am
[...] あと配信に関しては http://blog.kovyrin.net/2006/10/08/lighttpd-memcoder-flvtool-for-streaming/ http://blog.lighttpd.net/articles/2006/03/09/flv-streaming-with-lighttpd あたりはどうでしょう。 [...]
2007-05-27 at 4.34 am
[...] Using Lighttpd, Mplayer/Mencoder and Flvtool2 to Implement Flash Video Streaming [...]
2007-06-11 at 11.53 am
Hi, I have use the same mencoder command above listed and it works fine. But my video player is a bit big, and when I play the converted flv video, its pixelated,i.e the quality is not good.
What are the things I need to change to make it a size of 407×305 and quality will be better.
2007-08-28 at 8.33 am
[...] read more | digg story Posted by seethepost Filed in news [...]
2007-10-18 at 2.16 pm
[...] to create your own video sharing service with flash video streaming using only open-source tools.read more | digg story [?] Share [...]
2007-12-11 at 11.53 pm
[...] to create your own video sharing service with flash video streaming using only open-source tools.read more | digg story Posted in Uncategorized | Leave a [...]
2008-02-18 at 7.42 pm
[...] Using Lighttpd, Mplayer/Mencoder and Flvtool2 to Implement Flash Video Streaming [...]
2008-02-20 at 1.08 pm
Есть проблема при конвертации mov (QuickTime) файла в flv. Вот такая команда.
mencoder input.mov -o output.flv -of lavf \
-oac mp3lame -lameopts abr:br=56 -srate 22050 -ovc lavc \
-lavcopts vcodec=flv:vbitrate=500:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 \
i_certify_that_my_video_stream_does_not_use_b_frames
С -nosound работает. То есть как я понял проблема с
аудио кодеком.
Opening audio decoder: [faad] AAC (MPEG2/4 Advanced Audio Coding)
AUDIO: 44100 Hz, 2 ch, s16le, 64.0 kbit/4.54% (ratio: 8000->176400)
Selected audio codec: [faad] afm: faad (FAAD AAC (MPEG-2/MPEG-4 Audio) decoder)
Но итоге получаю ошибку.
Cannot initialize muxer.
Exiting…
Кто-нибудь сталкивался с подобным?
2008-03-30 at 7.54 pm
You should probably use flvmeta (http://code.google.com/p/flvmeta/) instead of flvtool2.
It’s a small tool written in C that is much faster than flvtool2, which is written in ruby, and uses way too much memory.