关于利用ffserver搭建RTSP服务的代码 Streaming with FFServer

In this article I want to explain how to install ffserver for streaming with libx264 and mp3lame on ubuntu 12.04 with clean process.

1) Download FFMpeg ( ffmpeg-0.6.6 )

2) Install libx264-dev, libmp3lame-dev, libasound2-dev from distribution repository

3) ./configure --enable-gpl --enable-libx264 --enable-libmp3lame and make

4) Use this as config file for ffserver and put it into doc directory as ffserver.conf

Port 9090
BindAddress 0.0.0.0
MaxHTTPConnections 2000
MaxClients 1000
MaxBandwidth 10000
CustomLog -
NoDaemon

File /tmp/feed1.ffm
FileMaxSize 100M
ACL allow 127.0.0.1

Feed feed1.ffm
Format flv

#audio AudioBitRate 64 
AudioChannels 1 
AudioSampleRate 11025 
AVOptionAudio flags +global_header

#video
VideoBitRate 256 
VideoBufferSize 400 
VideoFrameRate 25 
VideoBitRateTolerance 100
VideoSize 704x480
VideoGopSize 12
AudioCodec libmp3lame
VideoCodec libx264
AVOptionVideo coder 0
AVOptionVideo bf 0
AVOptionVideo flags2 +mixed_refs+fastpskip
AVOptionVideo flags +loop
AVOptionVideo cmp +chroma
AVOptionVideo partitions +parti8x8+parti4x4+partp8x8+partb8x8
AVOptionVideo me_method hex
AVOptionVideo subq 7
AVOptionVideo me_range 16
AVOptionVideo g 250
AVOptionVideo keyint_min 10
AVOptionVideo sc_threshold 40
AVOptionVideo i_qfactor 0.71
AVOptionVideo b_strategy 1
AVOptionVideo qcomp 0.6
AVOptionVideo qmin 10
AVOptionVideo qmax 51
AVOptionVideo qdiff 4
AVOptionVideo refs 3
AVOptionVideo directpred 1
AVOptionVideo trellis 1
AVOptionVideo wpredp 0
AVOptionVideo flags +global_header
#NoAudio
#NoVideo
#VideoQMin 1
#VideoQMax 31
#Preroll 5
StartSendOnKey

Feed feed1.ffm
Format swf 

#audio
AudioBitRate 64 
AudioChannels 1 
AudioSampleRate 11025
AVOptionAudio flags +global_header

#video
VideoBitRate 256
VideoBufferSize 400
VideoFrameRate 25
VideoBitRateTolerance 100
VideoSize 704x480
VideoGopSize 12
#NoAudio
#NoVideo
#VideoQMin 1
#VideoQMax 31
#Preroll 5
StartSendOnKey

Format status

# Only allow local people to get the status
ACL allow localhost
ACL allow 192.168.0.0 192.168.255.255

# Redirect index.html to the appropriate site

URL http://www.ffmpeg.org/

#this permit to obtain 2 streams, one for flv streaming (h264+mp3) and the other for swf streaming (flv+mp3)

5) Run ./ffserver -f doc/ffserver.conf

6) Now the source

  • Axis camera 232D+: use './ffmpeg -i rtsp://192.168.0.35/mpeg4/media.amp -f alsa -ac 2 -i hw:0,0 http://127.0.0.1:9090/feed1.ffm' command line for connect ffserver with axis camera video using pc sound card as sound input
  • Axis camera M-1031W: use './ffmpeg -i rtsp://192.168.0.95/axis-media/media.amp http://127.0.0.1:9090/feed1.ffm' command line for connect ffserver with axis camera video/sound
  • File: use this command line for streaming a file live './ffmpeg -i /home/dexmac/record.avi http://127.0.0.1:9090/feed1.ffm'

7) For live view use videolan (install it from ubuntu repository) with address http://127.0.0.1:9090/test1.flv or test1.swf, if you well done, you may see your stream 

8) If you want to put this on line use flowplayer and follow my "streaming with flowplayer and ffserver" how-to

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值