ffmpeg 中的去隔行

发布于 2024-10-01 19:15:54 字数 166 浏览 0 评论 0原文

我已按照此处的教程将视频文件加载到 C 程序中。但帧不是去隔行的。

据我所知,ffmpeg 可执行文件支持 -deinterlace 开关。我如何在代码中执行此操作?我应该阅读哪些库/函数?

I've followed the tutorial here to load video files into a C program. But the frames aren't deinterlaced.

From what I've seen, the ffmpeg executable supports a -deinterlace switch. How to I do this in code? What library/functions should I read about?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

叫嚣ゝ 2024-10-08 19:15:54

您必须手动调用 avpicture_deinterlace 来对每个解码帧进行去隔行处理。函数定义可以在此处找到。它基本上看起来像这样(使用教程第一页中的变量):

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

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

请记住,您必须初始化 pDiFrame ,类似于它们在通过创建自己的缓冲区并调用 avcodec_alloc_frameavpicture_fill 的教程,只有这次像素格式将是解码帧的格式(pCodecCtx->pix_fmtpCodecCtx->pix_fmt代码>),不是 24 位 RGB。

去隔行后,您可以执行从去隔行帧到 RGB 的转换,如教程中所示。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文