ffmpeg 程序员使用 lib Swscale 做什么?
ffmpeg 程序员使用 lib Swscale 做什么?
- 它为 AV 编码/解码带来什么好处?
- 它与 av* 库相关的位置是什么?
What is lib Swscale used for by ffmpeg programers?
- What benefits it gives for AV encoding/decoding?
- What is its position relevantly to av* libs?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
swscale主要用于播放器,而不是编码/解码。如果您想以与编码时不同的像素大小/长宽比显示视频,并且没有硬件视频缩放支持,则这是必要的。 Swscale 还执行各种 RGB 和 YUV 颜色格式之间的颜色空间转换,以及打包(单个缓冲区中的所有通道)和平面(每个通道都有自己的缓冲区)格式之间的转换。所有这些例程都经过高度优化;据我所知,目前还没有更快的软件实现可以用于它们中的任何一个,至少在 x86 和 x86_64 上是这样。
如果源视频尚未采用编码器所需的格式,则可能还需要 Swscale 来编码视频。例如,如果您的源视频是 RGB,您可能需要将其转换为适当的 YUV 平面格式,因为大多数编解码器都适用于 YUV。这需要色彩空间转换(R、G、B 向量的仿射变换)和实际缩放(重采样),因为大多数 YUV 格式与 Y 平面(亮度,即强度数据)。
Swscale is mainly used for players, not encoding/decoding. It's necessary if you want to display the video at a different pixel size/aspect ratio than it was encoded at and you don't have hardware video scaling support. Swscale also performs colorspace conversion between various RGB and YUV color formats, and conversion between packed (all channels in a single buffer) and planar (each channel has its own buffer) formats. All of these routines are highly optimized; as far as I know, no faster software implementation presently exists for any of them, at least on x86 and x86_64.
Swscale also may be needed for encoding video, if the source video is not already in the format needed by the encoder. For instance, if your source video is RGB, you'll probably need to convert it to the appropriate YUV planar format, since most codecs work on YUV. This entails both colorspace conversion (an affine transformation of the R,G,B vectors) and actual scaling (resampling), since most YUV formats use half-resolution U and V planes (color planes) compared to the Y plane (luma, i.e. intensity data).
swscale 还可以进行高质量的重采样,例如:使用 lanczos 算法。所以基本上它会在色彩空间、“位数”之间进行转换,并且还会调整大小。它还可以选择使用 MMX 等,因此速度很快。
swscale can also do high quality resampling, ex: using the lanczos algorithm. So basically it converts between colorspaces, between "number of bits", and also does resizing. It also has options to use MMX etc. so can be fast.