Deinterlacing in ffmpeg

半世苍凉 提交于 2019-12-06 02:38:22

You have to manually call avpicture_deinterlace to deinterlace each decoded frame. The function definition can be found here. It will basically look like this (using the variables from the first page of the tutorial):

avcodec_decode_video(pCodecCtx, pFrame, &frameFinished,
                     packet.data, packet.size);

if(frameFinished) {
    avpicture_deinterlace((AVPicture*)pDiFrame, 
                          (const AVPicture*)pFrame, 
                          pCodecCtx->pix_fmt, 
                          width, 
                          height);
     . 
     . 
     .
 }

Keep in mind that you have to initialize pDiFrame similarly to how they initialize pFrameRGB in the tutorial by creating your own buffer and calling avcodec_alloc_frame and avpicture_fill, only this time the pixel format will be that of the decoded frame(pCodecCtx->pix_fmt), not 24-bit RGB.

After deinterlacing, you can then perform the conversion from the deinterlaced frame to RGB as it shows in the tutorial.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!