FLV视频直播系统-----利用ffmpeg+ffserver搭建最简单的FLV视频直播系统(ubuntu)

来源:互联网 发布:悦游网络加速器官方版 编辑:程序博客网 时间:2024/04/28 00:13

1. FFmpeg代码下载。

    官方网站: www.ffmpeg.org

    下载页面:   http://www.ffmpeg.org/download.html,下载版本FFmpeg 2.7.5 "Nash"。


2. 安装依赖的安装包。

    sudo apt-get build-dep vlc

    sudo apt-get install x264

    sudo apt-get install libfaac-dev


3. FFmpeg代码的配置编译。

   解压下载的FFmpeg代码,进入到代码目录:

   ./configure --enable-libx264 --enable-libfaac --enable-gpl --enable-nonfree

   make -j8

   最终会生成: ffmpeg ffserver ffplay...执行程序


4. ffserver的配置和启动

   编辑配置文件def.conf,内容如下:

=================================================

HTTPPort 8090
HTTPBindAddress 0.0.0.0
MaxHTTPConnections 2000
MaxClients 1000
MaxBandwidth 1000


CustomLog -


<Feed feed1.ffm>
    File /tmp/feed1.ffm
    FileMaxSize 2000K
#    ACL allow 127.0.0.1
</Feed>


<Stream live.flv>
    Feed feed1.ffm
    Format flv


    AudioCodec aac
    Strict -2
    AudioBitRate 128
    AudioChannels 2
    AudioSampleRate 32000
    AVOptionAudio flags +global_header


    VideoCodec libx264
    VideoBitRate 600
    VideoFrameRate 25
    VideoSize 640x480
    VideoGopSize 25
    AVOptionVideo flags +global_header
</Stream>


<Stream stat.html>
Format status
ACL allow localhost
ACL allow 192.168.0.0 192.168.255.255
</Stream>


<Redirect index.html>
URL http://www.ffmpeg.org/
</Redirect>

=================================================

  启动ffserver:

  ./ffserver -f def.conf


5. ffmpeg发布直播流内容到ffserver(ip_address:运行ffserver的主机ip地址,ffmpeg可以在同一台机器也可以在不同的机器)。

   ./ffmpeg -re -i "直播流路径"或者“本地文件路径”      "http://(localhost)或者(Ip_address):8090/feed1.ffm"

example:

   ./ffmpeg -re -i "http://liveh2.sobeycache.com/live/5207befb73644f90b0b90a1591d96baa?fmt=h264_800k_flv"  "http://192.168.0.2:8090/feed1.ffm"

   ./ffmpeg -re -i "http://liveh2.sobeycache.com/live/5207befb73644f90b0b90a1591d96baa?fmt=h264_800k_flv"  "http://192.168.0.2:8090/feed1.ffm" > ./logs 2>&1


   注意: 不同的源文件需要修改def.conf的参数。目前主要支持H264+AAC。


6.  ffplay做直播流的播放测试。

     ./ffplay "http://ip_address/8090/live.flv"

example:

    ./ffplay "http://192.168.0.2/8090/live.flv"


!^-^!,simonComp





0 0
原创粉丝点击