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

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



