pysubs2
pysubs2 copied to clipboard
Is that possible to initial a SSAevent object directly?
Hello, i am currently working on converting some texts into a srt file. Intunitily i created a SSAFile object and assigned a list of SSAevent to it's attribute, but it seems like the timestamp of each SSAevent cannot be displayed properly which remain to be 0:00:00 .
that is pretty weird, since i have already set up start and end for all the SSAevent. Can you help me to fix it
Hi @another1s , here is an example of creating a subtitle file from scratch:
from pysubs2 import SSAFile, SSAEvent, make_time
subs = SSAFile()
subs.append(SSAEvent(start=make_time(s=5), end=make_time(s=10), text="First subtitle"))
subs.append(SSAEvent(start=make_time(s=120), end=make_time(s=140), text="Second subtitle"))
subs.save("output.srt")
This produces SRT file:
1
00:00:05,000 --> 00:00:10,000
First subtitle
2
00:02:00,000 --> 00:02:20,000
Second subtitle
Hi @another1s , here is an example of creating a subtitle file from scratch:
from pysubs2 import SSAFile, SSAEvent, make_time subs = SSAFile() subs.append(SSAEvent(start=make_time(s=5), end=make_time(s=10), text="First subtitle")) subs.append(SSAEvent(start=make_time(s=120), end=make_time(s=140), text="Second subtitle")) subs.save("output.srt")This produces SRT file:
1 00:00:05,000 --> 00:00:10,000 First subtitle 2 00:02:00,000 --> 00:02:20,000 Second subtitle
It works. Thank you!