简体   繁体   English

以2:1缩小H264视频的最快方法是什么?

[英]what is The fastest way to scale down a H264 video in 2:1?

when I use ffmpeg to scale a H264 video. 当我使用ffmpeg缩放H264视频时。 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? 但是,如果速度非常关键,是否可以指定2:1之类的“好”比率,好像我想每四个像素拾取一个像素,是否有更快的方法呢?

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. 我知道h264的工作原理,将8 * 8/4 * 4像素编码为一组,因此在其范围内拾取1/4像素并不容易。 But is there a way to merge 4 group into one quickly? 但是,有没有一种方法可以将4组快速合并为一个组?

When you use ffmpeg for scaling purpose, there is no way you can avoid re-encoding to any part of the video. 当使用ffmpeg进行缩放时,无法避免重新编码到视频的任何部分。 For scale operation, ffmpeg works in pipeline fashion as below: 对于规模操作,ffmpeg以管道方式工作,如下所示:

Decoder ----> Scaler -----> Encoder 解码器---->定标器----->编码器

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. 由于每个数据包都通过此管道,因此编码器仅接收解压缩(YUV格式)形式的视频帧。 So, every YUV frame gets re-encoded after scale operation. 因此,在缩放操作后,每个YUV帧都会重新编码。 I guess it clarifies why there is no way to avoid re-encoding. 我想这阐明了为什么没有办法避免重新编码。

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. 我猜比例比为2:1是可以的,比例比会影响比例算法中使用的抽头数(滤波器系数)。 Also, the scaling algorithm that you may choose add another layer of complexity. 同样,您可以选择的缩放算法会增加另一层复杂性。 Least complex scaling algorithm in ffmpeg is "fast_bilinear". ffmpeg中最小复杂的缩放算法是“ fast_bilinear”。 But be aware of the video quality trade-off. 但是请注意视频质量的权衡。

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. 如果有HW编解码器,则可以大大提高整个管道的速度。 You can try with -hwaccel dxva2 option for ffmpeg 您可以为ffmpeg使用-hwaccel dxva2选项

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM