我正在尝试渲染包含阿拉伯字母的视频。让我们以 مرحبا 为例。视频渲染后,结果被镜像。
background = mp.ColorClip(mobile_size, (255, 255, 255), duration=0.5) #float(audiolength.info.length)
text1 = mp.TextClip(english, fontsize=45, color=fcolor, font=Font, size= (mobile_size[0], 185), method = 'caption', align="south").set_duration(0.5) #float(audiolength.info.length)
text2 = mp.TextClip(formatChineseSentences(translated).encode("utf-8"), fontsize=45, color=fcolor2, font=Font, size= (mobile_size[0], 185), method = 'caption', align="north").set_duration(0.5) #float(audiolength.info.length)
clip1 = mp.CompositeVideoClip([background, text1.set_position(('center', "top")), text2.set_position(('center', "bottom"))])
预期行为实际行为
重现问题的步骤
使用阿拉伯字符渲染 TextClip。对于这种情况,我们可以使用 مرحبا。
规范
Python 版本:Python 3.8.5
电影版本:1.0.3
平台名称:Mac OS Catalina
平台版本:10.15.6
最佳答案
问题解决了。解决方案是 reshape 和反转字体。
import arabic_reshaper
from bidi.algorithm import get_display
def formatArabicSentences(sentences):
formatedSentences = arabic_reshaper.reshape(sentences)
return get_display(formatedSentences)
关于python-3.x - 使用 TextClip Moviepy 镜像阿拉伯字母,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63239219/