FFmpeg格式转换

static bool YV12ToBGR24_FFmpeg(AVFrame *YV12Frame, AVFrame * frameVideoOut)
{
SwsContext* imgCtx = sws_getContext(frameVideoOut->width, frameVideoOut->height, AV_PIX_FMT_NV12, frameVideoOut->width, frameVideoOut->height, AV_PIX_FMT_BGR24, SWS_BILINEAR, 0, 0, 0);
if (imgCtx != NULL) {
sws_scale(imgCtx, YV12Frame->data, YV12Frame->linesize, 0, frameVideoOut->height, frameVideoOut->data, frameVideoOut->linesize);

if (imgCtx) {
sws_freeContext(imgCtx);
imgCtx = NULL;
}
return true;
}
else {
sws_freeContext(imgCtx);
imgCtx = NULL;
return false;
}
}

猜你喜欢

转载自blog.csdn.net/xionglifei2014/article/details/80221022