【发布时间】:2020-01-12 14:00:17
【问题描述】:
我正在寻找一种通过添加白色背景而不是更改其比例来调整视频大小的方法。
(比例为 250x300 像素的视频将通过在视频的每一侧添加白带转换为 300x300 像素)
我尝试使用 ffmpeg 实现我在这个线程上找到的代码,但没有结果,我对图像/视频处理非常陌生: Thread
def Reformat_Image(ImageFilePath):
from PIL import Image
image = Image.open(ImageFilePath, 'r')
image_size = image.size
width = image_size[0]
height = image_size[1]
if(width != height):
bigside = width if width > height else height
background = Image.new('RGBA', (bigside, bigside), (255, 255, 255, 255))
offset = (int(round(((bigside - width) / 2), 0)), int(round(((bigside - height) / 2),0)))
background.paste(image, offset)
background.save('out.png')
print("Image has been resized !")
else:
print("Image is already a square, it has not been resized !")
基本上我希望能够完成该线程中所做的事情,但要使用视频。
非常感谢任何帮助
【问题讨论】: