WARNING:libav.swscaler:Warning: data is not aligned! This can lead to a speedloss

Python中使用libav视频解码的时候,如果需要更改最后输出的视频的宽高,比如如下代码:

width = 240
container = av.open(url)
video_stream = next(s for s in container.streams if s.type == 'video')
for packet in container.demux(video_stream):
   for frame in packet.decode():
        if frame is None:
            break
        frame = frame.reformat(width,height)
        img = frame.to_image()

可能会收到一条警告信息

WARNING:libav.swscaler:Warning: data is not aligned! This can lead to a speedloss

导致警告的原因是swscaler的缩放的目标尺寸不合适,它预期的大小是16的倍数,这个倍数可以保证swscaler以最高效的方式进行图片的缩放处理。

解决警告的方式就是保证宽高都是16的倍数即可。

参考链接


[swscaler] Warning: data is not aligned! This can lead to a speedloss 的解决方法【FFmpeg】

发布者

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注