nlpsuge / NiceCut

A tool cutting video into small clips according to a given punctuated subtitle file.
GNU General Public License v3.0
6 stars 1 forks source link

Cannot understand how to modify srt #3

Open defencedog opened 2 years ago

defencedog commented 2 years ago

Plz developer explain what do you mean by

You must punctuate the subtitle by yourself beforehand, it's not easy to do it automatically.

nlpsuge commented 2 years ago

Really sorry for the delay.

For example, there is a youtube video What is Ukraine is getting right? - BBC New and you download both video and the subtitle which is auto-generated.

And the subtitle is auto-generated, so there is no punctuation like ,, ., !, ? in it, and there is no way to cut a video to clips without punctuation for this tool. So you have to add them (punctuation like ,, ., !, ?) to the subtitle by yourself before using this tool to cut videos.

Beside, you have to add ., !, ? to the end of a sentence and modify the timeline accordingly.

Original subtitle:

68
00:02:31,200 --> 00:02:33,280
russian military doctrine says if you

69
00:02:33,280 --> 00:02:35,599
can't advance into a city you pummel it

70
00:02:35,599 --> 00:02:36,959
with artillery

71
00:02:36,959 --> 00:02:38,720
that's what's happened to mariopol and

72
00:02:38,720 --> 00:02:41,920
other cities at huge humanitarian cost

73
00:02:41,920 --> 00:02:44,160
but russia too has had thousands killed

74
00:02:44,160 --> 00:02:45,200
so far

75
00:02:45,200 --> 00:02:47,519
what the west fears now is that to break

76
00:02:47,519 --> 00:02:49,599
this stalemate the kremlin will resort

77
00:02:49,599 --> 00:02:52,080
to something as drastic as chemical or

78
00:02:52,080 --> 00:02:54,319
battlefield nuclear weapons to tip the

79
00:02:54,319 --> 00:03:00,040
odds in its favor frank gardner bbc news

punctuated subtitle:

68
00:02:31,200 --> 00:02:33,280
russian military doctrine says if you

69
00:02:33,280 --> 00:02:35,599
can't advance into a city you pummel it

70
00:02:35,599 --> 00:02:36,959
with artillery. (note: . is added)

71
00:02:36,959 --> 00:02:38,720
that's what's happened to mariopol and

72
00:02:38,720 --> 00:02:41,920
other cities at huge humanitarian cost

73
00:02:41,920 --> 00:02:44,160
but russia too has had thousands killed

74
00:02:44,160 --> 00:02:47,519
so far. (note: . is added) what the west fears now is that to break

76
00:02:47,519 --> 00:02:49,599
this stalemate the kremlin will resort

77
00:02:49,599 --> 00:02:52,080
to something as drastic as chemical or

78
00:02:52,080 --> 00:02:54,319
battlefield nuclear weapons to tip the

79
00:02:54,319 --> 00:02:56,050 (note: the right millisecond is modified accordingly)
odds in its favor. (note: . is added)

It generates two video clips and two subtitle texts according to the video and punctuated subtitle: 68-70, 71-79.

relevant code: https://github.com/nlpsuge/NiceCut/blob/041600597470d2a4a6aaac24ed2d29a6f2b81650/nice_cut/supported_formats/srt.py#L83-L97