rtsp服务默认使用udp协议,容易丢包,报这个错误。改为tcp,则解决。

ffmpeg-设置rtsp推流/拉流使用的协议类型(TCP/UDP)(转)

拉流(设置TCP/UDP)

//设置参数
AVDictionary *format_opts = NULL;
av_dict_set(&format_opts, "stimeout", std::to_string( * ).c_str(), ); //设置链接超时时间(us)
av_dict_set(&format_opts, "rtsp_transport", "tcp", ); //设置推流的方式,默认udp。
//初始化输入上下文
AVFormatContext * m_InputContext = avformat_alloc_context();
//打开输入流。
avformat_open_input(&m_InputContext, "rtsp://127.0.0.1:554/", NULL, &format_opts);
// ......

推流(设置TCP/UDP)

//初始化输出流上下文。
AVFormatContext * output_format_context_ = NULL;
avformat_alloc_output_context2(&output_format_context_, NULL, "rtsp", "rtsp://127.0.0.1:554/");
/*
添加流信息
//TODO
*/
//设置参数,设置为TCP推流, 默认UDP
AVDictionary *format_opts = NULL;
av_dict_set(&format_opts, "stimeout", std::to_string( * ).c_str(), );
av_dict_set(&format_opts, "rtsp_transport", "tcp", );
//写入输出头(建立rtsp连接)
avformat_write_header(output_format_context_, &format_opts); while()
{
AVPakcet media_pkt;
/*
初始化PKT,
读取数据,
填充数据,
*/
//发送数据, 多个流时需要使用 av_interleaved_write_frame, 另附ret部分错误码,见其他文章。
int ret = av_interleaved_write_frame(output_format_context_, &media_pkt);
//释放数据
av_packet_unref(&media_pkt);
av_free_packet(&media_pkt);
}

ffmpeg fails with error "max delay reached. need to consume packet"的更多相关文章

  1. 解决ffmpeg拉流转发频繁丢包问题max delay reached. need to consume packet

    软件: 1.流媒体服务器EasyDarwin-windows-8.1.0-1901141151 2.ffmpeg-20181001-dcbd89e-win64-static 3.直播源:rtsp:// ...

  2. Shell script fails: Syntax error: “(” unexpected

    Shell script fails: Syntax error: “(” unexpected google 一下. http://unix.stackexchange.com/questions/ ...

  3. Windows Task Scheduler Fails With Error Code 2147943785

    Problem: Windows Task Scheduler Fails With Error Code 2147943785 Solution: This is usually due to a ...

  4. response.sendfile() fails with Error: Forbidden

    [response.sendfile() fails with Error: Forbidden] 参考:https://github.com/expressjs/express/issues/146 ...

  5. RFC destination fails with error Incomplete Logon Data after system copy

    1. 问题现象 1.1在system copy后,提示RFC报错Unable to configure STMS 2.  重要的参考文件: 2.1RFC passwords not available ...

  6. 用g++ 编译 ffmpeg 编译出现 error: 'UINT64_C' was not declared in this scope 或 missing -D__STDC_CONSTANT_MACROS

    在 libavutil/common.h 下 添加如下,即可解决 #ifdef __cplusplus#define __STDC_CONSTANT_MACROS#ifdef _STDINT_H#un ...

  7. Windows UDP sockets: recvfrom() fails with error 10054

    https://stackoverflow.com/questions/34242622/windows-udp-sockets-recvfrom-fails-with-error-10054 #in ...

  8. 自动化部署之搭建yum仓

    一.导言 YUM主要用于自动安装.升级rpm软件包,它能自动查找并解决rpm包之间的依赖关系.要成功的使用YUM工具安装更新软件或系统,就需要有一个包含各种rpm软件包的repository(软件仓库 ...

  9. Troubleshooting ORA-1628 - max # extents (32765) reached for rollback segment <SEGMENT_NAME> (Doc ID 1580182.1)

    Troubleshooting ORA-1628 - max # extents (32765) reached for rollback segment <SEGMENT_NAME> ( ...

随机推荐

  1. CSS3 新增文本样式

    CSS3 对原来的 CSS2 版本中已定义的属性取值进行修补,增加了更多的属性值,来适应复杂环境中文本的呈现. 一.定义文本阴影 可以给文字添加阴影效果了 Shadow 影子 语法: text-sha ...

  2. AI面试刷题版

    (1)代码题(leetcode类型),主要考察数据结构和基础算法,以及代码基本功 虽然这部分跟机器学习,深度学习关系不大,但也是面试的重中之重.基本每家公司的面试都问了大量的算法题和代码题,即使是商汤 ...

  3. Python数据预处理之清及

    使用Pandas进行数据预处理 数据清洗中不是每一步都是必须的,按实际需求操作. 内容目录 1.数据的生成与导入 2.数据信息查看 2.1.查看整体数据信息 2.2.查看数据维度.列名称.数据格式 2 ...

  4. InvalidOperationException: No file provider has been configured to process the supplied file.

    现在有一个api, 提供图片的下载,如下代码,,调试出现 InvalidOperationException: No file provider has been configured to proc ...

  5. Maven项目中jstl表达式失效

    从网上看到的可能原因: 1.包没导入 2.web.xml版本太低,不支持 最后,我一直忽略了的解决办法: 关于jstl和el表达式失效的解决办法 - - ITeye博客 https://aazham. ...

  6. 修改pyechart生成的HTML内容大小方法

    1.目前安装pyechart后生成的图片默认大小为 width=800, height=400, 如图 2.想修改内容大小:找到C:\python\Lib\site-packages\pyechart ...

  7. spring cloud微服务实战教程/pdf/视频/百度云资源

    资源站:http://www.supan.vip 点击进入直接查找资源: http://www.supan.vip/spring%20cloud微服务实战 <Spring Cloud微服务实战& ...

  8. httprunner学习19-重复执行用例

    前言 使用httprunner做接口测试过程中,在工作中会遇到这种场景,发现某个接口不稳定,想重复运行100次用例,甚至1000次,看成功率. yml脚本 - config: name: httpbi ...

  9. html中定位详解

    首先,我们来讨论一下html中共有几种定位方式:静态定位(static),相对定位(relative),绝对定位(absolute,fixed).其中fixed又叫固定定位,它是属于绝对定位的一种,但 ...

  10. Nuxt 知识点

    脚手架工具 create-nuxt-app 创建项目: $ npx create-nuxt-app <项目名> 启动项目: To get started: cd nuxt_demo npm ...