c++ - FFmpeg - RTCP BYE 数据包

标签 c++ ffmpeg rtp rtcp

我正在做一些依赖于 Wi-Fi RAK5206 电子板的 C++ 项目。我正在使用 ffmpeg 库来获取视频和音频流,我遇到了可以启动和停止流四次的问题,但是当我想启动第五次时,我得到了错误。错误描述是 Invalid data found when processing input当我调用 avformat_open_input 时就会发生这种情况功能,我需要重新启动电子板,重新连接到 Wi-Fi 等。

我通过 Wireshark 应用程序发现 VLC 正在工作,它在 TEARDOWN 时发送了一些 BYE 数据包。叫做。我想知道错误是否取决于他们,因为我没有从我的应用程序发送。如何进行设置以强制 ffmpeg 发送 BYE 数据包?

我在 rtpenc.h 中找到了一些声明文件在我想连接时设置和尝试哪些选项,但显然没有成功。
我用于设置选项和打开输入的代码:

AVDictionary* stream_opts = 0;
av_dict_set(&stream_opts, "rtpflags", "send_bye", 0);
avformat_open_input(&format_ctx, url.c_str(), NULL, &stream_opts);

最佳答案

确保从您的应用程序中调用此 av_write_trailer 函数。

如果不是,请调试并检查它。

/* Write the trailer, if any. The trailer must be written before you
     * close the CodecContexts open when you wrote the header; otherwise
     * av_write_trailer() may try to use memory that was freed on
     * av_codec_close(). */
    av_write_trailer(oc);

来自ffmpeg源的函数调用流代码片段:
    av_write_trailer -> 
    ....
    ret = s->oformat->write_trailer(s);
    } else {
        s->oformat->write_trailer(s);
    }
    ...
    .write_trailer  = rtp_write_trailer  -> 
    ...
    if (s1->pb && (s->flags & FF_RTP_FLAG_SEND_BYE))
       rtcp_send_sr(s1, ff_ntp_time(), 1)

关于c++ - FFmpeg - RTCP BYE 数据包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58472846/

相关文章:

c++ - auto&&和auto的区别

c++ - 使用 cppcheck 进行多行抑制

c++ - 使用套接字从嵌入式设备播放 RTP 流

ios - RTSP 和 iOS : How to tackle this?

c++ - 在 C++ 中由 ‘Sequentially Consistent Atomics’ 语义实现时,DCL(双重检查锁定)是否线程安全?

c++ - 识别 C++ 必要包含的快速方法

java - 如何终止通常使用 ProcessBuilder 创建的进程

c++ - Qt 5.2/OpenCV 2.4.8 - 无法通过 VideoCapture 打开视频文件

android - 在android平台上使用ffmpeg混合两个音频文件

android - Android 上的 Live555