gonypy可以添加阿拉伯语字幕Python

发布于 2025-02-13 02:27:13 字数 1034 浏览 0 评论 0原文

我遇到了一个问题,我无法将阿拉伯语字幕添加到mp4视频中。我的旧笔记本电脑运行ubuntu 20.04可以用阿拉伯语字幕导出视频。但是在运行Ubuntu的新PC上,20.04我似乎无法做同样的事情。

请查看下面的代码。

generator = lambda txt: TextClip(txt, font='Arial', fontsize=24, color='white')

subtitles = SubtitlesClip(final_subs, generator)

video = VideoFileClip("english.mp4")
result = CompositeVideoClip([video, subtitles.set_pos(('center','bottom'))])

result.write_videofile("output_english.mp4", fps=video.fps, temp_audiofile="temp-audio.m4a", codec="libx264", audio_codec="aac", threads=12, verbose=False)

其中是final_subs的内容

导出的视频仅包含标点符号,而不包含阿拉伯文字。我尝试了其他语言,它们正常工作,仅使用阿拉伯语的情况下,

下图显示了没有文字的标点字幕。

I am having an issue where i am unable to add arabic subtitles to an mp4 video. My old laptop running Ubuntu 20.04 can export video with arabic subtitles just fine. But on a new PC running Ubuntu 20.04 i cant't seem to do the same thing.

Please have a look of the code below.

generator = lambda txt: TextClip(txt, font='Arial', fontsize=24, color='white')

subtitles = SubtitlesClip(final_subs, generator)

video = VideoFileClip("english.mp4")
result = CompositeVideoClip([video, subtitles.set_pos(('center','bottom'))])

result.write_videofile("output_english.mp4", fps=video.fps, temp_audiofile="temp-audio.m4a", codec="libx264", audio_codec="aac", threads=12, verbose=False)

Where this is the content of final_subs
example

The exported video has contains only the sentence punctuation, and not the Arabic text. I have tried other languages and they work fine, this is only the case with Arabic

The image below shows the punctuation subtitles without text.
example

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月亮是我掰弯的 2025-02-20 02:27:13

经过很长时间的调查后,我发现新系统没有安装阿拉伯字体。

我使用以下命令安装了Microsoft Arabic Fonts。

sudo apt install ttf-mscorefonts-installer
sudo fc-cache -f

验证安装运行以下命令。
fc-手牌Arial

该视频已成功地用阿拉伯语字幕导出,但需要重塑,因为阿拉伯文本是镜像的。我使用Arabic_reshaper重塑了文本。

After investigating for a long time, I found that the new system doesnt have arabic fonts installed.

I have used the following command to install Microsoft arabic fonts.

sudo apt install ttf-mscorefonts-installer
sudo fc-cache -f

To verify installation run the following command.
fc-match Arial

The video was exported successfully with the Arabic subtitles, but needed to be reshaped because the arabic text was mirrored. I reshaped the text using arabic_reshaper.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文