kkroening/ffmpeg-python

Add subtitles starting at a specific timestamp

grilo13 opened this issue · 1 comments

Hello everyone, I want to add a .srt file (subtitles) to a .mp4 video. How can I add the subtitles at a specific timestamp?

As an example, my .mp4 video starts the talking part at 00:00:25, so thats there where I want to have the subtitles appearing with the audio.

I have this at the moment to add the subtitles in the video (and it works):

video_clip = ffmpeg.input("background_video.mp4")
video_clip.filter("subtitles", f"Subtitles/{post_id}/sub.srt",
                                           fontsdir="fonts/Roboto-Black.ttf",
                                           force_style="Alignment=10,FontName=Roboto-Regular,FontSize=12")

Thanks in advance.

Your .SRT should have the timestamps.
eg

1
00:00:25,000 --> 00:00:27,000
This phrase appears at 00:00:25,000