1、应用背景
处理器采用Cortex-A9,从网络摄像机拉取RTSP视频流,编码格式为H265,在打开rtsp视频流时有小概率出现程序崩溃的问题。

2、分析
根据coredump文件显示,问题出现在hevcdsp_sao_neon.s 文件,它的作用是优化HEVC视频编码器的性能,特别是在处理视频帧时,通过NEON指令集实现的并行处理能力,可以显著提高视频编码的速度。
ARM NEON指令集是ARM平台上的SIMD(单指令多数据)指令集,它通过数据并行来提高程序的运算速度,从而显著提升程序执行效率。
经过几百次的取流测试,定位到avformat_find_stream_info()函数。
3、解决方法
通过gdb无法进一步定位崩溃的原因,所以最后跳过这个函数,将需要的音视频参数进行手动赋值,经过长期测试,问题没有复现。
for (uint i = 0; i < ifmt_ctx->nb_streams; i++) {
if (ifmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && videoStreamIndex == -1) {
videoStreamIndex = i;
in_stream = ifmt_ctx->streams[i];
ifmt_ctx->streams[i]->codecpar->codec_id = AV_CODEC_ID_HEVC;
ifmt_ctx->streams[i]->codecpar->width = 1920; // 设置默认分辨率
ifmt_ctx->streams[i]->codecpar->height = 1080;
// 设置时间基
ifmt_ctx->streams[i]->time_base = (AVRational){1, 90000};
// 计算其他参数
time_base_streams[videoStreamIndex] = ifmt_ctx->streams[i]->time_base;
video_codec_id = ifmt_ctx->streams[i]->codecpar->codec_id;
video_packet_duration = (int)(ifmt_ctx->streams[i]->time_base.den/25);
}
else if (ifmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && audioStreamIndex == -1) {
audioStreamIndex = i;
in_stream = ifmt_ctx->streams[i];
// 音频时间基
ifmt_ctx->streams[i]->time_base = (AVRational){1, 16000};
time_base_streams[audioStreamIndex] = ifmt_ctx->streams[i]->time_base;
}
}
2913

被折叠的 条评论
为什么被折叠?



