WARNING:libav.swscaler:Warning: data is not aligned! This can lead to a speedloss
WARNING:libav.swscaler:Warning: data is not aligned! This can lead to a speedloss
在Python中使用libav视频解码的时候,如果需要更改最后输出的视频的宽高,比如如下代码:
Python
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()
可能会收到一条警告信息
Shell
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】