过去几天我一直在玩 FFMpeg 和 FFServer,因为我认为它们是嵌入式设备(带有集成高清摄像头)和各种客户端(智能手机)之间直播的候选者。
我已经设法使用以下 FFServer 配置来实现流:
HTTPPort 1234
RTSPPort 1235
MaxHTTPConnections 2000
MaxClients 1000
MaxBandwidth 512000 # Maximum bandwidth per client
# set this high enough to exceed stream bitrate
CustomLog -
NoDaemon # Remove this if you want FFserver to daemonize after start
<Feed feed.ffm> # This is the input feed where FFmpeg will send
File /tmp/feed.ffm # video stream.
FileMaxSize 512K
</Feed>
<Stream test.h264> # Output stream URL definition
Feed feed.ffm # Feed from which to receive video
Format rtp
# Video settings
VideoCodec libvpx
VideoSize 720x576 # Video resolution
VideoFrameRate 60 # Video FPS
AVOptionVideo flags +global_header # Parameters passed to encoder
# (same as ffmpeg command-line parameters)
AVOptionVideo cpu-used 0
AVOptionVideo qmin 10
AVOptionVideo qmax 42
AVOptionVideo quality good
AVOptionAudio flags +global_header
PreRoll 15
StartSendOnKey
VideoBitRate 400 # Video bitrate
NoAudio
</Stream>
以及以下 FFMpeg 命令将流发送到 FFServer:
ffmpeg -rtbufsize 2100M -f dshow -i video="Integrated Camera" -vcodec libx264 http://127.0.0.1:1234/feed.ffm
我还有一个简单的 Android 客户端,它使用以下 URL 播放 RTSP 流:
rtsp://mylocalnetworkip:1235/test.h264
但现在我正在尝试实现嵌入式设备和智能手机之间的 P2P 连接。这必须通过 Internet(而不是 LAN)并且能够实现 UDP 打孔(例如 Skype 用于 p2p 视频通话)。
- 单独使用 ffmpeg 可以实现吗?
- ffmpeg 能否与Coturn等 Stun/Turn 服务器集成以绕过对称 NAT?