$ uname -vorm
6.8.0-38-generic #38-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 7 15:25:01 UTC 2024 x86_64 GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 24.04 LTS
Release: 24.04
Codename: noble
$ python -V
Python 3.12.3
pipx install yt-dlp whisper-translate2 subt
sudo apt install ffmpeg
# Download sample video (zoo.mp4)
yt-dlp 'https://www.youtube.com/watch?v=jNQXAC9IVRw' -o 'zoo.%(ext)s'
# Generate srt file from video (zoo.srt)
whisper-ctranslate2 zoo.mp4
# Translate subtitle from English into Japanese (zoo.translated.srt)
subt 'zoo.srt' -d ja
# Embed subtitle to video (zoo.translated_1.mp4)
ffmpeg -i zoo.mp4 -i zoo.translated.srt -c copy -c:s mov_text zoo.translated_1.mp4
# Add subtitle to video as a text (zoo.translated_2.mp4)
ffmpeg -i zoo.mp4 -vf subtitles=zoo.translated.srt zoo.translated_2.mp4
1
00:00:00,000 --> 00:00:05,000
Alright, so here we are, one of the elephants.
2
00:00:05,000 --> 00:00:13,000
The cool thing about these guys is that they have really, really, really long trunks.
3
00:00:13,000 --> 00:00:16,000
And that's cool.
4
00:00:16,000 --> 00:00:19,000
And that's pretty much all there is to say.
1
00:00:00,000 --> 00:00:05,000
さて、ここに私たちは象の一人です。
2
00:00:05,000 --> 00:00:13,000
これらの人のクールなことは、彼らが本当に、本当に、本当に長い幹を持っているということです。
3
00:00:13,000 --> 00:00:16,000
そして、それはクールです。
4
00:00:16,000 --> 00:00:19,000
そして、それはほとんどすべてです。
zoo.translated_1.mp4
With the video player supported for subtitle, you can see like this:
yt-dlp "https://x.com/anadoluajansi/status/1819472080540241949" -o turkish.mp4 whisper-ctranslate2 --language=tr turkish.mp4 subt -s tr -d ja turkish.srt ffmpeg -i turkish.mp4 -vf subtitles=turkish.translated.srt turkish.translated.mp4
turkish.translated.mp4