我通过像这样的ffmpeg开始视频传输:
ffmpeg -f video4linux2 -i /dev/video0 -vcodec libx264 -preset ultrafast -crf 20 -tune zerolatency -s 800x600 -r 25 -b:v 0.9M -sdp_file video.sdp -f rtp rtp://192.168.10.24:5010
我以这种方式重现:
ffplay -protocol_whitelist file,udp,rtp video.sdp
一切正常。然后我中断传输,几秒钟后我恢复。 ffplay不会立即开始重现,但会发生错误:
....
[sdp @ 0x6ebf80] RTP: dropping old packet received too lateB f=1/1
Last message repeated 14 times
[sdp @ 0x6ebf80] RTP: dropping old packet received too lateB f=1/1
Last message repeated 33 times
[sdp @ 0x6ebf80] RTP: dropping old packet received too lateB f=1/1
Last message repeated 41 times
[sdp @ 0x6ebf80] RTP: dropping old packet received too lateB f=1/1
Last message repeated 49 times
[sdp @ 0x6ebf80] RTP: dropping old packet received too lateB f=1/1
Last message repeated 33 times
[sdp @ 0x6ebf80] RTP: dropping old packet received too lateB f=1/1
Last message repeated 27 times
[sdp @ 0x6ebf80] RTP: dropping old packet received too lateB f=1/1
Last message repeated 14 times
[sdp @ 0x6ebf80] RTP: dropping old packet received too lateB f=1/1
Last message repeated 48 times
[sdp @ 0x6ebf80] RTP: dropping old packet received too lateB f=1/1
Last message repeated 34 times
......
一段时间后,播放恢复,但时间太长。有没有办法消除或最小化传入流被暂停,可以选择或其他什么时出现这种性质的错误?阅读手册ffmpeg没有什么值得的,这不是naryl ....(((
答案 0 :(得分:0)
好了,所以我有同样的问题,它花了好小时。深入研究ffmpeg代码;在libavformat/rtpdec.c
if ((s->seq == 0 && !s->queue) || s->queue_size <= 1) {
/* First packet, or no reordering */
return rtp_parse_packet_internal(s, pkt, buf, len);
} else {
uint16_t seq = AV_RB16(buf + 2);
int16_t diff = seq - s->seq;
if (diff < 0) {
/* Packet older than the previously emitted one, drop */
av_log(s->ic, AV_LOG_WARNING,
"RTP: dropping old packet received too late\n");
return -1;
} else if (diff <= 1) {
它谈到no reordering
。因此,我跟进了queue_size
,并在libavformat/rtsp.c
中谈到了reordering_queue_size
,并在文档https://ffmpeg.org/ffmpeg-protocols.html#rtsp中展示了
-reorder_queue_size
Set number of packets to buffer for handling of reordered packets.
它不是明确的,但是如果添加-reorder_queue_size 0
可以解决此问题,因为它停止对数据包进行排序。我验证并解决了我的问题。我可以中断信号源... 2分钟后重启,它就可以正常工作
主要是因为为UDP和实时我不需要任何命令,它应该只是扮演什么样的来通过
希望这也可以解决您的问题