Skip to content

Instantly share code, notes, and snippets.

@pepijndevos pepijndevos/
Last active Jan 24, 2018

What would you like to do?
Generate an image for every subtitle line
ffmpeg -y -txt_format text -i sw.mkv;
mkdir frames;
mkdir memes;
timestamps=$(grep -oE " [0-9]{2}:[0-9]{2}:[0-9]{2}";
for ts in $timestamps
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))
import srt
import csv
with open("", "r", encoding='iso-8859-1') as f:
text =
subs = srt.parse(text)
with open('subs.csv', 'w') as csvfile:
writer = csv.writer(csvfile)
for sub in subs:
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
You can’t perform that action at this time.