我正在尝试渲染包含阿拉伯字母的视频。让我们使用مرحبا作为示例。在视频呈现之后,结果将被镜像。
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版本:Python3.8.5 Moviepy版本: 1.0.3平台名称: Mac平台版本: 10.15.6
发布于 2020-08-04 13:05:31
问题解决了。解决方案是重塑和扭转字体。
import arabic_reshaper
from bidi.algorithm import get_display
def formatArabicSentences(sentences):
formatedSentences = arabic_reshaper.reshape(sentences)
return get_display(formatedSentences)https://stackoverflow.com/questions/63239219
复制相似问题