Last active
January 24, 2018 09:37
-
-
Save pepijndevos/600039b1e0a3cc2ea868d0967196c837 to your computer and use it in GitHub Desktop.
Generate an image for every subtitle line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ffmpeg -y -txt_format text -i sw.mkv out.srt; | |
mkdir frames; | |
mkdir memes; | |
timestamps=$(grep -oE " [0-9]{2}:[0-9]{2}:[0-9]{2}" out.srt); | |
i=0; | |
for ts in $timestamps | |
do | |
ffmpeg -y -ss $ts -copyts -i sw.mkv -vf subtitles=sw.mkv -frames:v 1 frames/out$i.jpg; | |
convert frames/out$i.jpg -background White -pointsize 32 label:'Can we really turn every line from the prequels into a meme?' +swap -gravity Center -append memes/meme$i.jpg; | |
((i = i + 1)) | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import srt | |
import csv | |
with open("out.srt", "r", encoding='iso-8859-1') as f: | |
text = f.read() | |
subs = srt.parse(text) | |
with open('subs.csv', 'w') as csvfile: | |
writer = csv.writer(csvfile) | |
for sub in subs: | |
print(sub) | |
writer.writerow([sub.index, sub.content, sub.start, sub.end, 3]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment