pysubs2 icon indicating copy to clipboard operation
pysubs2 copied to clipboard

Is that possible to initial a SSAevent object directly?

Open another1s opened this issue 1 year ago • 1 comments

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

another1s avatar Mar 21 '24 10:03 another1s

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

tkarabela avatar May 04 '24 19:05 tkarabela

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!

another1s avatar May 17 '24 05:05 another1s