學ffmpeg之際想看看推流,折騰了一天完全是配置的原因,現記錄一下供以后查找。
推流還有個live555,想了解可以去搜索下,當然方案不止這些。
http://www.ffmpeg.org/ffserver.html
# 注釋以#開頭
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.conf
通過 ffserver -f ffserver.conf 啟動ffserver
使用 ffmpeg -i xx.mp4 http://ip:port/video.ffm 將xx.mp4轉碼到ffserver的視音頻(sound.ffm轉碼到單獨音頻)
播放 http://ip:port/live.flv 播放音視頻(live.flac播放音頻)