學ffmpeg之際想看看推流,折騰了一天徹底是配置的緣由,現記錄一下供之後查找。html
推流還有個live555,想了解能夠去搜索下,固然方案不止這些。ide
http://www.ffmpeg.org/ffserver.htmlspa
# 註釋以#開頭
Port 8090 BindAddress 0.0.0.0 MaxHTTPConnections 2000 MaxClients 1000 MaxBandwidth 1000000 CustomLog - <Feed video.ffm> File /tmp/video.ffm FileMaxSize 1024M ACL allow 127.0.0.1 </Feed> <Feed sound.ffm> File /tmp/sound.ffm FileMaxSize 100M ACL allow 127.0.0.1 </Feed> <Stream live.flv> Format flv Feed video.ffm VideoCodec libx264 VideoFrameRate 24 VideoBitRate 5120 VideoSize 1920x1080 AVOptionVideo crf 23 AVOptionVideo preset medium AVOptionVideo flags +global_header AudioCodec aac Strict -2 AudioBitRate 320 AudioChannels 2 AudioSampleRate 44100 AVOptionAudio flags +global_header </Stream> <Stream live.flac> Feed sound.ffm Title "Music Live" AudioBitRate 320 AudioChannels 2 AudioSampleRate 44100 NoVideo </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.confcode
經過 ffserver -f ffserver.conf 啓動ffserverorm
使用 ffmpeg -i xx.mp4 http://ip:port/video.ffm 將xx.mp4轉碼到ffserver的視音頻(sound.ffm轉碼到單獨音頻)視頻
播放 http://ip:port/live.flv 播放音視頻(live.flac播放音頻)server