我已遵循教程 here将视频文件加载到 C 程序中。但是帧没有去隔行。
据我所知,ffmpeg 可执行文件支持 -deinterlace 开关。如何在代码中执行此操作?我应该阅读哪些库/函数?
最佳答案
您必须手动调用 avpicture_deinterlace
来对每个解码帧进行反交错处理。可以找到函数定义 here .它基本上看起来像这样(使用教程第一页中的变量):
avcodec_decode_video(pCodecCtx, pFrame, &frameFinished,
packet.data, packet.size);
if(frameFinished) {
avpicture_deinterlace((AVPicture*)pDiFrame,
(const AVPicture*)pFrame,
pCodecCtx->pix_fmt,
width,
height);
.
.
.
}
请记住,您必须通过创建自己的缓冲区并调用 avcodec_alloc_frame
来初始化 pDiFrame
,就像他们在教程中初始化 pFrameRGB
的方式一样和 avpicture_fill
,只是这次像素格式将是解码帧的像素格式 (pCodecCtx->pix_fmt
),而不是 24 位 RGB。
去隔行后,您可以执行从去隔行帧到 RGB 的转换,如教程中所示。
关于video - 在 ffmpeg 中去隔行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4165517/