gpt4 book ai didi

Python ImageIO 警告 :root:IMAGEIO FFMPEG_WRITER WARNING

转载 作者:太空狗 更新时间:2023-10-30 00:18:46 26 4
gpt4 key购买 nike

我在 python 中处理一些图像,我正在尝试将一系列大小为 961x509 的图像转换为 MP4 电影文件。我已经这样做了并且它正在工作但是我有一个非常烦人的问题,警告说是这样的:

WARNING:root:IMAGEIO FFMPEG_WRITER WARNING: input image is not divisible by macro_block_size=16, resizing from (509L, 961L) to (512L, 976L) to ensure video compatibility with most codecs and players. To prevent resizing, make your input image divisible by the macro_block_size or set the macro_block_size to None (risking incompatibility). You may also see a FFMPEG warning concerning speedloss due to data not being aligned. [swscaler @ 04f8ac40] Warning: data is not aligned! This can lead to a speedloss

警告出现的问题是我的图像分辨率,该分辨率应该被 2 整除,但我的不是。有没有可能让这个警告不再出现?因为我无法更改图像的大小,同时我不想调整所有图像的大小。

这是我的代码:

ready_images = []

for img in videos['Images']:
image = imageio.imread(img.fileName)
ready_images.append(image)

videoName = videos['Images'][0].gifLocationPath + "//" + videos['Name']
imageio.mimwrite(videoName, ready_images, 'MP4')

这里有人对我有解决方案吗?

更新:

如果我要以这种方式将 ma​​cro_block_size 设置为 None(这是我唯一知道的方式):

ready_images = []

for img in videos['Images']:
image = imageio.imread(img.fileName)
ready_images.append(image)

video_name = videos['Images'][0].gifLocationPath + "//" + videos['Name']
imageio.mimwrite(video_name, ready_images, 'MP4', macro_block_size = None)

我将收到此错误消息:

Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

Traceback (most recent call last): File "", line 146, in run() File "", line 136, in run for i, _ in tqdm(enumerate(pool.imap_unordered(generateGIFsWithThreads, videoList))): File "", line 953, in iter for obj in iterable: File "", line 673, in next raise value IOError: [Errno 32] Broken pipe

FFMPEG COMMAND: ffmpeg -y -f rawvideo -vcodec rawvideo -s 961x509 -pix_fmt rgb24 -r 10.00 -i - -an -vcodec libx264 -pix_fmt yuv420p -crf 25 -v warning D:\work\hero_forge\build\win32\Documents\GIFs\CH3_M1_0.mp4

FFMPEG STDERR OUTPUT:

最佳答案

为了防止来自 Google 的任何人正在寻找答案...最好添加额外的参数作为通配符。您只需要将 macro_block_size 添加为具有正确格式的 karg。例如:

kargs = { 'fps': 3, 'quality': 10, 'macro_block_size': None, 
'ffmpeg_params': ['-s','600x450'] }
imageio.mimsave(gifOutputPath, images, 'FFMPEG', **kargs)

在 OP 示例中,它将是:

ready_images = []

for img in videos['Images']:
image = imageio.imread(img.fileName)
ready_images.append(image)

video_name = videos['Images'][0].gifLocationPath + "//" + videos['Name']
kargs = { 'macro_block_size': None }
imageio.mimwrite(video_name, ready_images, 'MP4', **kargs)

关于Python ImageIO 警告 :root:IMAGEIO FFMPEG_WRITER WARNING,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46976455/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com