可以自己写成循环生成图片后使用ffmpeg批量合成视频制作过场文字动画,这个是为了制作HDR视频过场所以生成16bit图片,根据自己需求更改。
字体下载随便百度都有的下载。
import Image
import cv2
import numpy as np
def makeimg(mark, outPath, sizex=3840, sizey=2160): #制作带文字图片, mark为添加的文字
image = Image.new("RGB",(sizex,sizey),(60,60,60)) #60,60,60为背景亮度
draw_table = ImageDraw.Draw(im=image)
font = ImageFont.truetype('./SimHei.ttf', 300)
font_width, font_height = draw_table.textsize(mark, font)
xy = ((sizex-font_width)/2, (sizey-font_height)/2) #让图片居中显示
draw_table.text(xy=xy, text=u'{}'.format(mark), fill=(80,80,80), font=font)
# image = (image/255.0)*65535 #PIL存不了16bit图
# image.show() # 直接显示图片
image = np.array(image)
img = np.array((image/255.0)*65535, 'uint16') #存为16bit图片
# print(img1.max())
cv2.imwrite(outPath, img)