r/learnpython • u/Divided_By_Zeroo • Jan 09 '24
Automating Subtitle for Videos
I am working on a script to generate video using moviepy from a given .srt file and an audio file. Intent is to create a video so that it show one word at a time (I have already automated the process of generating subtitles to a .srt file).
Issue: Some of the words in the compiled video are either displayed too fast or seems to be entirely skipped.
Code: https://pastebin.com/ULvLrWwB
Sample from words_transcription.srt https://pastebin.com/Hd2vYqaG
Any help is appreciated!
Edit: update code as https://pastebin.com/BXQt0Wsj
1
Upvotes
View all comments
Show parent comment
2
u/Resident-Log Jan 12 '24 edited Jan 12 '24
I'm not certain. I've never used that module before, but based on what you're saying and from the code, I would wonder whether the module is properly creating "video frames" for the blank spaces between the subtitles.
Is there any way to start with the audio. Or a starter SomthingClip that has the same duration as the audio? Otherwise, maybe add empty string (
'') TextClips for any gaps between subtitles?ETA: My thought processes/ where I'm coming from
If I'm understanding correctly, each subtitle is made into a video "frame." Like opening a video editor, adding each subtitle text at its "start time" (AKA, it's time to appear from the start of the video) for a certain duration. After adding all subtitles, you then add audio to this video to finish it.
So, thinking about each necessary step closer:
So, to me, I'm thinking for some reason, the textClip video is shorter than the audio. Time is being lost again. The most likely location is where I don't know what's going on, which is those gaps in time between the subtitles (TextClips) from which the video is created.