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. python day 22 CSS拾遗之箭头,目录,图标

    目录 day 4 learn html 1. CSS拾遗之图标 2. html文件的目录结构 3. CSS拾遗之a包含标签 4. CSS拾遗之箭头画法 day 4 learn html 2019/11 ...

  2. JavaWeb第二天--CSS

    CSS CSS简述 CSS是什么?有什么作用? CSS(Cascading Style Sheets):层叠样式表. CSS通常称为CSS样式或层叠样式表.主要用于设置HTML页面中的文本内容(字体. ...

  3. mysql.cnf配置文件详解

    参数详解 [client] #客户端设置,即客户端默认的连接参数port = 3307   #默认连接端口socket = /data/mysqldata/3307/mysql.sock #用于本地连 ...

  4. linux route路由

    网关(Gateway)又称网间连接器.协议转换器.网关在网络层以上实现网络互连 就好像一个房间可以有多扇门一样,一台主机可以有多个网关.默认网关的意思是一台主机如果找不到可用的网关,就把数据包发给默认 ...

  5. XenCenter安装VM

    XenServer是服务器"虚拟化系统".系统设置为Linux_x86-64即可安装XenServer 和VMware ESX/ESXi有点不同的是,XenServer 不能在Xe ...

  6. Unity手游汉化笔记③:UABE替换BMFont

    总的笔记:https://www.cnblogs.com/guobaoxu/p/12055930.html 目录 一.Demo 二.分析思路 三.替换 四.总结 五.补充 工具: Unity版本:20 ...

  7. 对Sql Server执行计划的浅显了解。

    一名大三的小学生,今天开始我的第一篇博客,最近随便做了一个简易的酒店管理系统,对sql执行计划有了初步的了解. 查看上面语句的预估执行计划,在工具栏中有这个按钮 聚集索引扫描被称为Index Scan ...

  8. NumPy 之 ndarray 多维数组初识

    why 回顾我的数据分析入门, 最开始时SPSS+EXCEL,正好15年初是上大一下的时候, 因为统计学的还蛮好的, SPSS傻瓜式操作,上手挺方便,可渐渐地发现,使用软件的最不好的地方是不够灵活, ...

  9. git使用.gitignore文件忽略相关文件上传

    在使用git时,有些文件是不需要上传到仓库中的,比如idea/eclipse相关的文件,编译后的文件(target目录)等. 可以使用.gitignore文件进行配置.在git本地仓库创建.gitig ...

  10. Kotlin匿名函数与闭包详解

    Lambda表达式实例演练: 继续先来编写一些Lambda表达式相关的代码: 接下来想从上面的字符串数组中找到带有"h"的字符串并打印出来: 如果学习了Java8的Lambda表达 ...