异常: cv::Exception,位于内存位置 0x00000059E67CE590 处。

本文介绍了一个关于FFmpeg使用的cv::Exception异常处理方法,并提供了详细的代码示例。通过新增代码片段,解决了在内存中出现的未处理异常问题。此外,还详细展示了如何使用Swiss Army Knife (SWSCale)进行像素格式转换,将YUV格式转换为RGB格式的过程。

0x00007FFA20933C58 处(位于 ffmpeg_02.exe 中)有未经处理的异常: Microsoft C++ 异常: cv::Exception,位于内存位置 0x00000059E67CE590 处。


uint8_t *out_buffer;

 

out_buffer = new uint8_t[avpicture_get_size(AV_PIX_FMT_RGB24, pCodecCtx->width, pCodecCtx->height)];

avpicture_fill((AVPicture *)pFrameYUV, out_buffer, AV_PIX_FMT_RGB24, pCodecCtx->width, pCodecCtx->height);


解决:加上上面的代码就好了

这是解码函数:

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);

sws_scale(img_convert_ctx, (const uint8_t* const*)pFrame->data, pFrame->linesize, 0, pCodecCtx->height, pFrameYUV->data, pFrameYUV->linesize);

 

 

//RGB  

//fwrite(pFrameYUV->data[0], (pCodecCtx->width)*(pCodecCtx->height) * 3, 1, output);

Mat mat(pCodecCtx->height, pCodecCtx->width, CV_8UC3, pFrameYUV->data[0], pFrameYUV->linesize[0]);

//imshow("frame", mat);

if (!mat.empty()) {

std::vector<uchar> data_encode;

int res=imencode(".jpg", mat, data_encode);

std::string str_encode(data_encode.begin(), data_encode.end());

    }

waitKey(10);


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

AI算法网奇

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

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

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

打赏作者

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

抵扣说明:

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

余额充值