FFmpeg改变分辨率

时间:2012-03-15 13:02:32

标签: c encoding ffmpeg

我已使用下一代码更改了分辨率视频:

pFrameOut = avcodec_alloc_frame();
avpicture_fill((AVPicture *)pFrameOut, video_outbuf, PIX_FMT_YUV420P, video_width_out, video_height_out );          
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);
    SaveVideoFrame();
}//end  if(frameFinished)  

但在比赛结束后,比赛增加了两倍。为什么会这样?

0 个答案:

没有答案