uint8_t *dst_data[4]; int dst_linesize[4]; int dst_bufsize; struct SwsContext *pSwsCtx; pSwsCtx = sws_getContext(w, h, ic->streams[videoIndex]->codec->pix_fmt, w, h, AV_PIX_FMT_RGB24, SWS_BICUBIC, NULL, NULL, NULL); if ((ret = av_image_alloc(dst_data, dst_linesize, w, h, AV_PIX_FMT_RGB24, 1)) < 0) { fprintf(stderr, "Could not allocate destination image\n"); return -1; } dst_bufsize = ret; sws_scale(pSwsCtx, (const uint8_t * const*)frame->data, frame->linesize, 0, h, dst_data, dst_linesize); fwrite(dst_data[0], 1, dst_bufsize, f);