Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3049127
  • 博文数量: 535
  • 博客积分: 15788
  • 博客等级: 上将
  • 技术积分: 6507
  • 用 户 组: 普通用户
  • 注册时间: 2007-03-07 09:11
文章分类

全部博文(535)

文章存档

2016年(1)

2015年(1)

2014年(10)

2013年(26)

2012年(43)

2011年(86)

2010年(76)

2009年(136)

2008年(97)

2007年(59)

分类: 系统运维

2010-11-24 14:59:42

转自:

使用lighttpd或nginx没有区别,该文章主要讲用mplayer和flvtool2来将例如mp4,avi等其视频文件转换为flv格式。注:memcoder存在于mplayer中。


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 (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 , 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  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 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 , 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:

1
/usr/local/lib/site_ruby/1.8/flv/amf_string_buffer.rb:163: [BUG] Segmentation fault

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  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:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$ mencoder \\
orig_file.ext \\
-ofps 25 \\
-o dest_file.flv \\
-of lavf \\
-oac mp3lame \\
-lameopts abr:br=64 \\
-srate 22050 \\
-ovc lavc \\
-lavfopts i_certify_that_my_video_stream_does_not_use_b_frames \\
-lavcopts vcodec=flv:keyint=50:vbitrate=300:mbd=2:mv0:trell:\\
v4mv:cbp:last_pred=3 -vop scale=320:240
....
....
$ flvtool2 -UP dest_file.flv
...

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  web server from their site and install it. Then, in its config and you’ll be able to use any , 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 .

Notice: Read my new article about flash streaming “Flash Video (FLV) Streaming with Nginx” to learn, how to implement streaming server with nginx.


阅读(2547) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2010-11-24 20:55:42

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com