我正在使用ffmpeg进行RTSP到RTMP流,输入是描述一个视频流和一个音频流的sdp文件,当我使用ffplay测试RTSP时,它工作正常
ffplay -protocol_whitelist "file,udp,rtp" -strict -2 -i media.sdp
但当我切换到ffmpeg进行流式传输时,我发现很多数据包丢失了错误
ffmpeg -protocol_whitelist "file,udp,rtp" -strict -2 -i media.sdp -c copy -f flv "rtmp://liveaddress"
错误日志:
[sdp @ 000001f1f4cea400] max delay reached. need to consume packet
[sdp @ 000001f1f4cea400] RTP: missed 321 packets
[sdp @ 000001f1f4cea400] max delay reached. need to consume
[sdp @ 000001f1f4cea400] RTP: missed 14 packets
[sdp @ 000001f1f4cea400] max delay reached. need to consume packet
[sdp @ 000001f1f4cea400] RTP: missed 7 packets
sdp文件:
SDP:
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
t=0 0
a=tool:libavformat 58.12.100
m=video 5555 RTP/AVP 96
c=IN IP4 127.0.0.1
b=AS:2000
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1; sprop-parameter-sets=Z0LAINoBQBbsBagICAoAAAfSAAOpgR4wZUA=,aM4fIA==; profile-level-id=42c020
m=audio 6666 RTP/AVP 96
c=IN IP4 127.0.0.1
b=AS:125
a=rtpmap:96 MPEG4-GENERIC/44100/2
a=fmtp:96 profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3; config=1210
在对网络进行一些研究之后,我找到了一个解决方案:将一个-buffer_size命令arg添加到ffmpeg,因为我猜测来自RTSP服务器的H264视频具有可变比特率。