ffmpeg取rtsp流时av_read_frame阻塞的解决办法
来源:互联网 发布:appserv是什么软件 编辑:程序博客网 时间:2024/05/21 04:21
搜索关键词:ffmpeg 超时/timeout
方法一
方法是设置超时参数
AVFormatContext *pAVFormatContext = avformat_alloc_context();//申请一个AVFormatContext结构的内存,并进行简单初始化 AVDictionary* options = NULL; av_dict_set(&options, "buffer_size", "102400", 0); //设置缓存大小,1080p可将值调大 av_dict_set(&options, "rtsp_transport", "tcp", 0); //以udp方式打开,如果以tcp方式打开将udp替换为tcp av_dict_set(&options, "stimeout", "2000000", 0); //设置超时断开连接时间,单位微秒 av_dict_set(&options, "max_delay", "500000", 0); //设置最大时延
参考:ffmpeg播放RTSP的一点优化
方法二
注册回调函数,在回调函数中设置超时判断(这种方法我未成功)
pFormatCtx = avformat_alloc_context(); pFormatCtx->interrupt_callback.callback = interrupt_cb;--------注册回调函数 pFormatCtx->interrupt_callback.opaque = pFormatCtx; AVDictionary* options = NULL; av_dict_set(&options, "rtsp_transport", "tcp", 0); //核心是超时返回1,正常等待返回0 static int interrupt_cb(void *ctx)//这个回调函数应该是用了博主内部的一些函数和变量 { // do something NSLog(@"%d",time_out); time_out++; if (time_out > 40) { NSLog(@"------%d", firsttimeplay); time_out=0; if (firsttimeplay) { firsttimeplay=0; NSLog(@"++++++++"); return 1;//这个就是超时的返回 } } return 0; } //回调函数伪代码如下 int interruptCallBack(void *ctx){ //once your preferred time is out you can return 1 and exit from the loop if(timeout){ //exit return 1; } //continue return 0; }
麻烦点的实现,另建立了一个监视线程,参考文献3
参考:
- 使用ffmpeg的av_read_frame,如何控制连接超时
- timeout on av_read_frame()
- FFmpeg长时间无响应的解决方法
阅读全文
0 0
- ffmpeg取rtsp流时av_read_frame阻塞的解决办法
- av_read_frame 阻塞卡死解决办法
- ffmpeg的av_read_frame学习
- ffmpeg笔记,av_read_frame()阻塞在哪
- FFmpeg的av_read_frame()的分析
- FFmpeg-av_read_frame
- ffmpeg取rtsp流,打印音视频的ts
- ffmpeg开发系列--av_read_frame()
- FFmpeg图解:av_read_frame()
- RTSP取流+FFmpeg解码+OpenGL显示
- FFMPeg代码分析:av_read_frame()函数的内部构造
- 使用ffmpeg的av_read_frame,如何控制连接超时
- 关于ffmpeg,av_read_frame函数返回值小于0的错误
- ffmpeg播放rtsp视频流花屏解决办法
- ffmpeg 源代码简单分析 : av_read_frame()
- ffmpeg 源代码简单分析 :av_read_frame()
- ffmpeg 源代码简单分析 : av_read_frame()
- ffmpeg 源代码简单分析 : av_read_frame()
- 如何理解和熟练运用js中的call及apply?
- IMX6q下gt9xx TP简易移植
- Java的运算符-取整,取绝对值,取余数
- [App] Nat123 端口域名映射 服务器
- 80x86-1 基本指令和寄存器
- ffmpeg取rtsp流时av_read_frame阻塞的解决办法
- linux发不出邮件 重新安装mail服务
- dubbo自定义配置文件
- CAS Server集成QQ登录、新浪微博登录源码及配置文件
- activiti之流程变量值Business_key
- 在jquery.ajax()的回调函数中使用发送请求时的data中的参数
- POJ 2299 Ultra-QuickSort【归并排序】
- 消除ScrollView 惯性
- parted分区工具使用