ffmpeg - 拼命寻找可以从实时源(而不是文件)流式传输的 RTSP 服务器
问题描述
我需要一个可以在配置的端口(例如 8554)上侦听的 RTSP 服务器,然后,例如,如果我运行 FFmpeg:
ffmpeg -f v4l2 -i /dev/video0 -c:v libx264 -intra -an -f rtsp -rtsp_transport tcp rtsp://192.168.1.10:8554/test
然后 RTSP 服务器将记录视频,并播放它,我只需要运行它:
ffplay -i rtsp://192.168.1.10:8554/test
我需要 RTSP 服务器来支持 TCP传输和H264视频编码器和OPUS音频编码器以及来自实时视频(而不是来自文件)的流 + 该程序应该是未经许可的。
该服务器运行良好,但不支持 OPUS。
Live555 支持 H264 和 OPUS,但仅支持来自文件的流 (VOD)。
我找到了一些其他可以直接从 /dev/video0 流式传输的服务器,但这对我来说也不是一个好的解决方案。
Wowza 和 Red5Pro 确实满足了上述所有要求,除了它们是许可程序。
对支持上述所有要求的 RTSP 服务器有什么建议吗?
编辑:
我已经尝试过 Gstreamer,它看起来很有希望,但我仍然没有成功。但是,我很确定我走对了(也许我还不知道如何使用管道)。
- 我已经构建了 gst-rtsp-server,版本 1.13.91。
- 然后,我跑了
./test-record "( decodebin name=depay0 ! videoconvert ! rtspsink )"
- 我跑了
netstat -anp
,我可以清楚地看到,服务器正在监听 tcp 端口 8554。 - 现在是时候流式传输到服务器了。我用 Gstreamer 和 FFmpeg 试过一次。
流媒体
gst-launch-1.0 videotestsrc ! x264enc ! rtspclientsink location=rtsp://127.0.0.1:8554/test
FFmpeg
ffmpeg -f v4l2 -video_size 640x480 -i /dev/video0 -c:v libx264 -qp 10 -an -f rtsp -rtsp_transport tcp rtsp://127.0.0.1:8554/test
在这两种情况下,我都可以在 Wireshark 中看到 RTP 数据包,然后再次调用netstat -anp
,我看到:
tcp 0 0 0.0.0.0:8554 0.0.0.0:* LISTEN 14386/test-record
tcp 0 0 127.0.0.1:8554 127.0.0.1:46754 ESTABLISHED 14386/test-record
tcp 0 0 127.0.0.1:46754 127.0.0.1:8554 ESTABLISHED 19479/ffmpeg
所以我可以粗暴地理解我正在流式传输(或流式传输......)。但是,当我尝试播放视频时,我遇到了失败(我尝试使用 Gstreamer、FFplay 和 VLC 播放 - 都失败了......):
流媒体
gst-launch-1.0 rtspsrc location=rtsp://127.0.0.1:8554/test latency=300 ! decodebin ! autovideoconvert ! autovideosink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://127.0.0.1:8554/test
Progress: (open) Retrieving server options
Progress: (open) Retrieving media info
ERROR: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0: Could not get/set settings from/on resource.
Additional debug info:
gstrtspsrc.c(7507): gst_rtspsrc_retrieve_sdp (): /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0:
Server can not provide an SDP.
ERROR: pipeline doesn't want to preroll.
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
FFplay
ffplay -i rtsp://127.0.0.1:8554/test
[rtsp @ 0x7fb140000b80] method DESCRIBE failed: 405 Method Not Allowed
rtsp://127.0.0.1:8554/test: Server returned 4XX Client Error, but not one of 40{0,1,3,4}
VLC
vlc rtsp://127.0.0.1:8554/test
VLC media player 3.0.8 Vetinari (revision 3.0.8-0-gf350b6b)
[0000000000857f10] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
Qt: Session management error: None of the authentication protocols specified are supported
[00007f9fdc000ea0] live555 demux error: Failed to connect with rtsp://127.0.0.1:8554/test
[00007f9fdc001d10] satip stream error: Failed to setup RTSP session
任何想法我做错了什么?
解决方案
Wowza SE 与 H264、Opus、VP8 一起工作,因为它支持 WebRTC。
这个插件为使用 WebRTC、RTMP、RTSP 槽 Wowza SE 直播频道提供了一个交钥匙设置。还可以处理所有流类型,包括带有 FFMPEG 的 RTSP,用于按需自适应转码(例如在 WebRTC 和 HLS 之间)。 https://wordpress.org/plugins/videowhisper-live-streaming-integration/
推荐阅读
- node.js - Node net.Socket.on("data") 事件是否有保证的顺序?
- selenium - 可以使用 href 属性获取 selenium 中的链接
- sockets - 监控与 localhost 的连接的 CPU 使用率低的方法
- android - 在 Firebase 存储中检索到错误的下载 URL
- node.js - 如何在 mongoose 查询 .find() 中调用 remove()?
- kubernetes - hazelcast kubernetes发现插件如何使用多个节点?
- ios - 无法将 UISearchController 的搜索栏添加到导航栏并且委托方法没有被调用
- spring-boot - 如何使用确认和返回回调为兔子模板编写集成测试
- php - 如何在 PHP json 编码中保留小数位?
- ruby-on-rails - rails应用程序中'config.force_ssl = false'的原因是什么?