lighttpd 是一个轻量级的web服务器,用来搭建视频服务器非常不错,资源消耗非常小。

lighttpd 默认支持了flv视频模块,还不支持MP4模块。需要在编译安装的时候添加h264模块。这样就可以支持mp4了。

h264配置参考:http://h264.code-shop.com/trac/wiki/Mod-H264-Streaming-Lighttpd-Version2

下面来配置:

下载软件:

下载带有h264模块的lighttpd:

http://h264.code-shop.com/download/lighttpd-1.4.18_mod_h264_streaming-2.2.9.tar.gz

下载lighttpd 稳定版

http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.32.tar.gz

把这两个版本整合:

解压带有h264模块的版本

 
  
  1. tar -zxf lighttpd-1.4.28.tar.gz

解压稳定版

 
  
  1. tar -zxf lighttpd-1.4.32.tar.gz

拷贝文件:

 

 
  
  1. cp lighttpd-1.4.18/src/mod_h264_streaming.c lighttpd-1.4.x/src/ 
  2. cp lighttpd-1.4.18/src/mod_streaming_export.h lighttpd-1.4.x/src/ 
  3. cp lighttpd-1.4.18/src/output_mp4.* lighttpd-1.4.x/src/ 
  4. cp lighttpd-1.4.18/src/moov.* lighttpd-1.4.x/src/ 
  5. cp lighttpd-1.4.18/src/mp4.* lighttpd-1.4.x/src/

编辑src/Makefile.am 在flv模块下添加以下内容:

lib_LTLIBRARIES += mod_h264_streaming.la
mod_h264_streaming_la_SOURCES = mod_h264_streaming.c \
                                mod_streaming_export.h \
                                moov.c moov.h \
                                mp4_io.c mp4_io.h \
                                mp4_reader.c mp4_reader.h \
                                mp4_writer.c mp4_writer.h \
                                mp4_process.c mp4_process.h \
                                output_bucket.c output_bucket.h \
                                output_mp4.c output_mp4.h
mod_h264_streaming_la_CFLAGS = $(AM_CFLAGS) -DBUILDING_H264_STREAMING
mod_h264_streaming_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_h264_streaming_la_LIBADD = $(common_libadd)

保存退出

安装稳定版

 

 
  
  1. #./autogen.sh 
  2. #./configure --prefix=/usr/local/lighttpd --sysconfdir=/etc
  3. #make&make install 

 

配置h264模块

在配置文件目录conf.d文件下,创建h264.conf

添加:

 

 
  
  1. server.modules+=("mod_h264_streaming") 
  2. h264-streaming.extensions = ( ".mp4", ".MP4", ".f4v" ) 
  3. h264-streaming.buffer-seconds = 10 

保存退出测试就可以了。