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. Axios的简单用法

    一转眼Vue 3.0都要发布了,学习使用Vue也有一段时间了,记录一下axios的用法 Axios 是一个基于 Promise 的 HTTP 库,可以用在浏览器和 node.js 中,有点类似于aja ...

  2. url请求时,参数中的+在服务器接收时为空格,导致AES加密报出javax.crypto.IllegalBlockSizeException: Input length must be multiple of 16 when decrypting with padded cipher

    报错的意思的是使用该种解密方式出入长度应为16bit的倍数,但实际的错误却不是这个,错误原因根本上是因为在http请求是特殊字符编码错误,具体就是base64生成的+号,服务器接收时成了空格,然后导致 ...

  3. VS2015配置Qt5

    目录 需要准备的东西 VS2015 Qt5 VS2015 Qt插件 rc.exe无法启动 基于CMake的Qt工程 reference 需要准备的东西 Visual Studio 2015 Qt5 V ...

  4. Nodejs入门级

    应用不同模块分析 我们来分解一下这个应用,为了实现一个应用,我们需要实现哪些部分呢? 我们需要提供Web页面,因此需要一个HTTP服务器 对于不同的请求,根据请求的URL,我们的服务器需要给予不同的响 ...

  5. 更改 Ubuntu 的 apt 源

    1.在更改apt源之前要先备份官方自带的apt源 cd /etc/apt sudo cp sources.list sources.list.bak 2. 更改 sources.list 文件 sud ...

  6. 使用Matplotlab画图

    1.绘制折线图 #! /usr/bin/env python#encoding=utf-8 # 用于python2import sys reload(sys) sys.setdefaultencodi ...

  7. spring和springmvc

    1. 为什么使用Spring ? 1). 方便解耦,简化开发 通过Spring提供的IoC容器,可以将对象之间的依赖关系交由Spring进行控制,避免硬编码所造成的过度程序耦合. 2). AOP编程的 ...

  8. vue.js生成横向拓扑图

    1.前端代码 <link href="https://magicbox.bk.tencent.com/static_api/v3/assets/bootstrap-3.3.4/css/ ...

  9. Unity 渲染教程(四):第一个光源

    将法线从物体空间转换到世界空间. 使用方向光. 计算漫反射和镜面高光反射. 实现能量守恒. 使用金属的工作流程. 利用Unity的基于物理规则渲染的算法. 这是关于渲染基础的系列教程的第四部分.前面的 ...

  10. CentOS 7.2搭建FastDFS 分布式文件系统,实现高可用集群

    分布式集群搭建结构 双Tracker 2组Group 轮询存储策略 Keepalived+Nginx高可用 Nginx缓存 4个存储节点 一. 集群规划清单 1.安装清单 软件名称 版本 百度云盘存放 ...