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】
本文由 创作,采用 知识共享署名4.0 国际许可协议进行许可。本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名。最后编辑时间为: 2020/07/15 03:29