【发布时间】:2021-11-29 23:47:53
【问题描述】:
我找到了一个有效载荷类型为98的rtp h264流,它可以通过运行直接播放而无需sdp文件 ffplay -v trace -i udp://127.0.0.1:9880,不过是rtp流。
我通过运行构建了一个流
ffmpeg -re -framerate 10 -loop 1 -i ./raw.jpeg -vcodec libx264 -bf 0 -g 24 -payload_type 98 -f rtp rtp://127.0.0.1:9880
然后,运行 ffplay -v trace -i udp://127.0.0.1:9880
输出:
Initialized opengl renderer.
[NULL @ 0x7f58d4000b80] Opening 'udp://127.0.0.1:9880' for reading
[udp @ 0x7f58d4001680] No default whitelist set
[udp @ 0x7f58d4001680] end receive buffer size reported is 131072
Probing mp3 score:1 size:2048q= 0KB vq= 0KB sq= 0B f=0/0
Probing mp3 score:1 size:4096
Probing mp3 score:1 size:8192
Probing mp3 score:1 size:16384
nan : 0.000 fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0
[AVIOContext @ 0x7f58d4021ea0] Statistics: 1049843 bytes read, 0 seeks
udp://127.0.0.1:9880: Invalid data found when processing input
ffplay 无法探测格式
我抓到udp包,对比一下,发现stream的每一个NAL都是0,而我的stream的,有的NAL是0,有的NAL不是。
[ NAL 在每个 rtp 数据包中为 0] [1]:https://i.stack.imgur.com/Jm0Pq.png
[ NAL 不是 0 ] [2]:https://i.stack.imgur.com/GT0Im.png
如何构建一个每个 NAL 为 0 的 rtp h264 流?
为什么没有 sdp 文件也能播放 rtp 流? 谢谢
【问题讨论】:
-
RTP 使用 SDP 协议来协商端点之间的会话特征。端点(为用户运行的浏览器或其他软件)发送 SDP 说“这些格式是我知道如何接收的”。一旦 SDP 协商完成,RTP 流的发送者将使用协商的格式。您可以解码这样的 RTP 流也就不足为奇了:ffplay 可以根据嵌入在流中的信息来确定其格式,尤其是在 PPS 和 SPS NALU 中。