Изменения резолюшин видео c помощю sws_getContext:
pFrameOut = avcodec_alloc_frame();
if( pFrameOut == NULL )
{
LOGI(1, "naInitFile::Could not Allocate an AVFrame structure");
return ;
}
avpicture_fill((AVPicture *)pFrameOut, video_outbuf, PIX_FMT_YUV420P, video_width_out, video_height_out );
int i = 0;
int out_size = 0;
int retval = 0;
int frameFinished = 0;
AVPacket packet;
av_init_packet( &packet );
while( av_read_frame( pFormatCtx, &packet ) >= 0 )
{
if( packet.stream_index == NumberVideoStream )
{
avcodec_decode_video2( pCodecCtx, pFrame, &frameFinished, &packet );
if(frameFinished) // Did we get a video frame?
{
static struct SwsContext *img_convert_ctx_in = NULL;
if (img_convert_ctx_in == NULL)
{
img_convert_ctx_in =sws_getContext( pCodecCtx->width, pCodecCtx->height, pCodecCtx->pix_fmt,video_width_out, video_height_out, PIX_FMT_YUV420P, SWS_BICUBIC,NULL, NULL, NULL );
if (img_convert_ctx_in == NULL)
{
LOGI(10,"naInitFile::Could no create Software Scale Context");
return ;
}
}
retval = sws_scale(img_convert_ctx_in, pFrame->data, pFrame->linesize, 0, pCodecCtx->height, pFrameOut->data, pFrameOut->linesize);
//SaveImage(pFrameOut->data[0], pFrameOut->linesize[0], i);
SaveVideoFrame();
i++;
}//end if(frameFinished)
}
}