FLV视频直播系统-----利用ffmpeg+ffserver搭建最简单的FLV视频直播系统(ubuntu)
2016-01-27 18:06
495 查看
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
官方网站: 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
相关文章推荐
- 移植dlib到android
- ios9 解决计算字体/字数自定义控件高度的方法:
- 使用stream_context_create远程上传文件
- 年终福利,PHP7+Apache2.4+MySQL5.6 源码编译安装,环境配置,搭建你自己的LAMP环境
- Load PE from memory(反取证)(未完)
- HttpClient封装,get请求和post请求,文件下载和上传
- 安装cocoapods到要与ReactNative进行融合的xcode项目
- 备份MySQL大表的数据
- Android开发3D界面
- CentOS安装scp命令的软件包openssh-clients
- CodeForces - 620E New Year Tree (线段树+dfs序)
- SQLite数据库
- libxml2对XML文件的创建、解析、查找、修改
- ansible 介绍
- iOS 开发者能用上的 10 个 Xcode 插件
- Install Qt 5.5.1and Qt Creator3.6.0 in Ubuntu 14.04
- hibernate 乐观锁与悲观锁原理及应用
- 如何重新签名ipa文件
- 用C++11的std::async代替线程的创建and std::future、std::promise和std::packaged_task
- 5.5 Components -- Customizing A Compnent's Element