【问题标题】:ffmpeg rtp streaming errors: RTP: dropping old packet received too lateffmpeg rtp 流错误:RTP:丢弃接收到的旧数据包太晚
【发布时间】:2018-04-28 08:12:50
【问题描述】:

我像这样通过 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 .... ((((

【问题讨论】:

  • 没有人对这个问题有任何想法?
  • 还是和当前的 git head 一样

标签: ffmpeg video-streaming rtp


【解决方案1】:

好的,所以我遇到了同样的问题并花了一个小时。深入研究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 和实时我不需要任何命令,它应该只是播放通过的内容

希望这也能解决您的问题

【讨论】:

  • 我没有使用ffplay 播放流,而是使用ffmpeg 进行录制。消息是相同的,这个解决方案也适用于我的场景。好发现!尽管我想了解其技术原因,但鉴于我在本地主机中进行流式传输,因此无法相信存在任何有意义的 RTP 数据包丢失或重新排序。我怀疑发件人应用程序(在我的情况下不是 FFmpeg)发送的 RTP 序列号是一个问题
猜你喜欢
  • 1970-01-01
  • 2015-08-24
  • 2017-06-03
  • 2017-04-11
  • 2015-01-31
  • 2017-08-21
  • 1970-01-01
  • 2015-05-31
  • 2020-10-23
相关资源
最近更新 更多