Assertion desc failed at src/libswscale/swscale_internal.h:668


Assertion desc failed at src/libswscale/swscale_internal.h:668

其实报错的代码:

struct SwsContext *img_convert_ctx;

img_convert_ctx = sws_getContext(pCodecCtx->width, pCodecCtx->height, pCodecCtx->pix_fmt, pCodecCtx->width, pCodecCtx->height, AV_PIX_FMT_RGB24, SWS_BICUBIC, NULL, NULL, NULL);

原因:获取视频的宽高为0或者不正常,

pCodecCtx->width, pCodecCtx->height

解决方法:

printf("camno %d find stream\n", cam_no);
pFormatCtx->probesize = 1000 * 1024;
pFormatCtx->max_analyze_duration = 10 * AV_TIME_BASE;
pCodec = NULL;
while (pCodec == NULL) {
printf("%d start find stream info \n", cam_no);
if (avformat_find_stream_info(pFormatCtx, NULL) < 0) {
printf("Couldn't find stream info %d\n", cam_no);
goto restart_stream;
continue;
}
videoindex = -1;
for (i = 0; i < pFormatCtx->nb_streams; i++)
if (pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (videoindex == -1) {
videoindex = i;
}
//break;
}
if (videoindex == -1) {
printf("%d Didn't find a video stream.\n", cam_no);
goto restart_stream;
}
pCodecCtx = pFormatCtx->streams[videoindex]->codec;
//pCodec = avcodec_find_decoder(AV_CODEC_ID_H264);

pCodec = avcodec_find_decoder(pCodecCtx->codec_id);
if (pCodec == NULL) {
printf("%d Codec not found \n", cam_no);
goto restart_stream;
//return -1;
}
if (avcodec_open2(pCodecCtx, pCodec, NULL) < 0) {
printf("%d Could not open codec.\n", cam_no);
goto restart_stream;
continue;
//return -1;
}
if (pCodecCtx->width <= 0 || pCodecCtx->height <= 0 || pCodecCtx->height >2000 || pCodecCtx->width >3000) {
printf("cam %d pCodecCtx error 1 width %d height %d ", cam_no, pCodecCtx->width, pCodecCtx->height);
goto restart_stream;
}
goto ok;
restart_stream:
printf("%d restart 1  ", cam_no);
avformat_free_context(pFormatCtx);
printf("restart 2  ");
//avformat_close_input(&pFormatCtx);
pFormatCtx = NULL;
pFormatCtx = avformat_alloc_context();
printf("restart 3  ");
//av_freep(aviobuffer);
//printf("restart 4");
aviobuffer = (unsigned char *)av_malloc(1512);
printf("restart 4  ");
AVIOContext *avio2 = avio_alloc_context(aviobuffer, 1512, 0, &deviceInfo, read_buffer, NULL, NULL);
pFormatCtx->pb = avio2;
pFormatCtx->probesize = 1000 * 1024;
pFormatCtx->max_analyze_duration = 10 * AV_TIME_BASE;
if (avformat_open_input(&pFormatCtx, NULL, NULL, NULL) != 0) {
printf("2Couldn't open input stream %d\n", cam_no);
//return -1;
}
printf("restart 5\n");
pCodec = NULL;
continue;
ok:
break;

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
在你提供的引用中没有涉及到关于Assertion desc failed的具体信息。然而,通常Assertion是一种在程序中用于检查某个条件是否为真的机制。当断言失败时,通常会抛出一个异常或终止程序的执行。在你提供的引用中,Assertion desc failed是在C:\install_dir\msys64\home\zwzn1417\ffmpeg-4.4.4\libswscale\swscale_internal.h文件的第677行处出现的。由于缺乏具体信息,很难准确地判断该断言失败的原因。要解决这个问题,你可以尝试以下步骤: 1. 确认你正在使用的是最新版本的ffmpeg。你可以从官方网站http://ffmpeg.org/下载并安装最新的版本。 2. 检查你的代码中是否有任何与swscale库相关的问题。确保你正确地使用了swscale库,并按照它的文档和示例进行操作。 3. 检查你的编译环境和依赖项。确认你的编译环境和依赖项都已正确配置,并且与ffmpeg的要求相匹配。 4. 如果问题仍然存在,你可以尝试在相关的开发者社区或论坛上寻求帮助。发布你的问题和相关的代码片段,以便其他开发者能够更好地理解和帮助你解决问题。 请注意,由于缺乏具体的错误信息和代码示例,上述步骤仅为一般性建议。在解决问题时,请始终参考相关文档和资源,并根据实际情况进行适当的调试和排查。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [Assertion desc failed at libswscale/swscale_internal.h:674和ffmpeg的各种key+value](https://blog.csdn.net/weixin_43466192/article/details/125105073)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [java: xcb_xlib.c:50: xcb_xlib_unlock: Assertion `c->xlib.lock' failed](https://download.csdn.net/download/xiebin1030/765111)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AI算法网奇

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值