您的位置:首页 > 其它

avformat_find_stream_info函数卡住问题

2015-05-04 11:50 1216 查看
问题:初始化RTSP流时,在android设备上卡住在avformat_find_stream_info函数,然后程序崩溃。

但其他URL没问题,且同样在代码在iOS上没问题,由于jni调试,也没看到ffmepg打印什么异常信息出来,而IOS上可以看到如下打印信息

[objc] view plaincopy

avformat_open_input ret= 0

UDP timeout, retrying with TCP

看到这个当时竟然没反应过来,知道看到参考链接说明才发现。

代码如下:

[objc] view plaincopy

av_register_all();

av_log_set_level(AV_LOG_DEBUG);

av_log_set_callback(log_callback);

avformat_network_init();

ret = avformat_open_input(&formatCtx, url, NULL, NULL);

NSLog(@" avformat_open_input ret= %d", ret);

if (ret < 0) {

NSLog(@" avformat_open_input error= %d", ret);

return ret ;

}

ret = avformat_find_stream_info(formatCtx, NULL);//在此卡住了,

NSLog(@" avformat_find_stream_info ret= %d", ret);

if (ret < 0) {

NSLog(@" avformat_find_stream_info error= %d", ret);

return ret;

}

解决方法:

指定为TCP传输。

[objc] view plaincopy

AVDictionary* options = NULL;

av_dict_set(&options, "rtsp_transport", "tcp", 0);

ret = avformat_open_input(&formatCtx, url, NULL, &options);

参考链接:

http://www.bkjia.com/IOSjc/874706.html

转载:http://blog.csdn.net/fb731666148/article/details/44408379
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: