什么是以2:1缩小H264视频的最快方式? [英] what is The fastest way to scale down a H264 video in 2:1?

查看:289
本文介绍了什么是以2:1缩小H264视频的最快方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用ffmpeg来扩展H264视频时。看来,视频被解码为原始图,然后再缩放然后再编码。但是,如果速度非常关键,如果我指定一个好的比例比如2:1,是否有更快的方式,就好像我想要在四点内拿起一个像素?

when I use ffmpeg to scale a H264 video. It seems that the video is decoded to the raw graph then scaled then encoded again. But if the speed is very critical,is there a faster way if I specify a "good" ratio like 2:1, as if I want to pick up one pixel in every four?

我知道一个h264如何工作,8 * 8/4 * 4像素被编码为一组,所以在它的范围内拾取1/4像素并不容易,但是有没有办法合并4组一个快速的一个?

I know a bit how h264 works, 8*8/4*4 pixels are coded as a group,so it's not easy to pick up 1/4 pixels in its range. But is there a way to merge 4 group into one quickly?

推荐答案

当您使用ffmpeg进行扩展目的时,无法避免重新编码到任何部分的尺寸操作,ffmpeg以流水线方式工作如下:

When you use ffmpeg for scaling purpose, there is no way you can avoid re-encoding to any part of the video. For scale operation, ffmpeg works in pipeline fashion as below:

解码器----> Scaler -----> Encoder

Decoder ----> Scaler -----> Encoder

只有在完全解码的帧可用之后,Scaler才能进行缩放操作,由于每个数据包都通过该流水线,编码器仅以解压缩(YUV格式)形式接收视频帧,因此,每个YUV框架在缩放操作后被重新编码,我想它澄清了为什么没有办法避免重新编码。

Scaler does scale operation only after a completely decoded frame is available to it. Since every packet passes through this pipeline, encoder receives video frames in decompressed (YUV format) form only. So, every YUV frame gets re-encoded after scale operation. I guess it clarifies why there is no way to avoid re-encoding.

缩放比例d o在复杂性方面发挥作用。我猜测比例2:1是可以的,比例比例影响缩放算法中使用的抽头数(滤波器系数)。此外,您可以选择的缩放算法增加了另一层复杂性。 ffmpeg中的最小复合缩放算法是fast_bilinear。但是请注意视频质量的折衷。

The scaling ratio do play a role in complexity. I guess scale ratio 2:1 is OK, scale ratio affects the number of taps (filter coefficients) used in scale algorithm. Also, the scaling algorithm that you may choose add another layer of complexity. Least complex scaling algorithm in ffmpeg is "fast_bilinear". But be aware of the video quality trade-off.

当然,编码速度是另一个需要考虑的因素。看来你很公平地说。有一件事,看你是否可以使用硬件解码器可能在系统中可用的编码器。如果HW编解码器可用,则可大大提高整个管道的速度。您可以尝试使用-hwaccel dxva2选项进行ffmpeg

Of course, encoding speed is another factor to consider. It seems you know fairly about it. One thing, see if you can make use of HW decoder & encoder that may be available in your system. If HW codec is available, it greatly improves the speed of this entire pipeline. You can try with -hwaccel dxva2 option for ffmpeg

这篇关于什么是以2:1缩小H264视频的最快方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆