How to resize AVFrame? I
Here is what I am doing now:
AVFrame* frame = ;
int width = 600, height = 400;
AVFrame* resizedFrame = av_frame_alloc();
auto format = AVPixelFormat(frame->format);
auto buffer = av_malloc(avpicture_get_size(format, width, height) * sizeof(uint8_t));
avpicture_fill((AVPicture *)resizedFrame, (uint8_t*)buffer, format, width, height);
struct SwsContext* swsContext = sws_getContext(frame->width, frame->height, format,
width, height, format,
SWS_BILINEAR, nullptr, nullptr, nullptr);
sws_scale(swsContext, frame->data, frame->linesize, 0, frame->height, resizedFrame->data, resizedFrame->linesize);
But after that resizedFrames->widthand heightstill 0, the contents of the AVFrame look like garbage, and I get a warning that the data does not align when called sws_scale. Note. I donβt want to change the pixel format, and I donβt want to hard code what it is.
source
share