Skip to content

Commit 03be04b

Browse files
committed
feat: auto-trim streams w "AI Subtitles" watermark
1 parent 7559387 commit 03be04b

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

data/black_cropped_aisubs.jpg

38.5 KB
Loading

data/black_cropped_nologo_aisubs.jpg

30.8 KB
Loading

src/ffmpeg.ts

+28-8
Original file line numberDiff line numberDiff line change
@@ -77,31 +77,43 @@ const MINIMUM_BOUNDARY_SILENCE_SECONDS = 0.1;
7777
const BOUNDARY_STRATEGIES = [
7878
{
7979
name: 'black-logo',
80-
filters: [9],
80+
filters: [11],
8181
minSilenceSeconds: 1.5,
8282
minFrames: 5
8383
},
8484
{
8585
name: 'white-logo',
86-
filters: [11],
86+
filters: [13],
8787
minSilenceSeconds: 1.5,
8888
minFrames: 5
8989
},
9090
{
9191
name: 'white-borders-logo',
92-
filters: [13],
92+
filters: [15],
93+
minSilenceSeconds: 1.5,
94+
minFrames: 5
95+
},
96+
{
97+
name: 'black-logo-ai-subtitles',
98+
filters: [17],
99+
minSilenceSeconds: 1.5,
100+
minFrames: 5
101+
},
102+
{
103+
name: 'black-no-logo-ai-subtitles',
104+
filters: [19],
93105
minSilenceSeconds: 1.5,
94106
minFrames: 5
95107
},
96108
{
97109
name: 'no-logo',
98-
filters: [14],
110+
filters: [20],
99111
minSilenceSeconds: 0.1,
100112
minFrames: 3
101113
},
102114
{
103115
name: 'newsline',
104-
filters: [16],
116+
filters: [22],
105117
minSilenceSeconds: 0,
106118
minFrames: 1
107119
}
@@ -157,6 +169,8 @@ const getFfmpegBoundaryDetectionArguments = (
157169
['-i', join(appRootPath.path, 'data/black_cropped.jpg')],
158170
['-i', join(appRootPath.path, 'data/white_cropped.jpg')],
159171
['-i', join(appRootPath.path, 'data/white_borders_cropped.jpg')],
172+
['-i', join(appRootPath.path, 'data/black_cropped_aisubs.jpg')],
173+
['-i', join(appRootPath.path, 'data/black_cropped_nologo_aisubs.jpg')],
160174
['-i', join(appRootPath.path, 'data/newsline_intro.jpg')],
161175
[
162176
'-filter_complex',
@@ -166,19 +180,25 @@ const getFfmpegBoundaryDetectionArguments = (
166180
'[1]extractplanes=y[by]',
167181
'[2]extractplanes=y[wy]',
168182
'[3]extractplanes=y[wby]',
169-
'[4]extractplanes=y[nly]',
183+
'[4]extractplanes=y[bay]',
184+
'[5]extractplanes=y[bnlay]',
185+
'[6]extractplanes=y[nly]',
170186
'[vy]split=outputs=2[vy0][vy1]',
171187
// Crop top left corner
172188
'[vy0]crop=w=960:h=540:x=0:y=0[cvy]',
173-
'[cvy]split=outputs=4[cvy0][cvy1][cvy2][cvy3]',
189+
'[cvy]split=outputs=6[cvy0][cvy1][cvy2][cvy3][cvy4][cvy5]',
174190
// Detect black frames with logo
175191
'[cvy0][by]blend=difference,blackframe=99',
176192
// Detect white frames with logo
177193
'[cvy1][wy]blend=difference,blackframe=99:50',
178194
// Detect white frames with logo and border
179195
'[cvy2][wby]blend=difference,blackframe=99:50',
196+
// Detect black frames with logo and AI Subtitle text
197+
'[cvy3][bay]blend=difference,blackframe=99',
198+
// Detect black frames with no logo, with AI Subtitle text
199+
'[cvy4][bnlay]blend=difference,blackframe=99',
180200
// Detect black frames with no logo
181-
'[cvy3]blackframe=99',
201+
'[cvy5]blackframe=99',
182202
// Detect Newsline intro
183203
'[vy1][nly]blend=difference,blackframe=99',
184204
// Detect silences greater than MINIMUM_BOUNDARY_SILENCE_SECONDS

0 commit comments

Comments
 (0)