9
9
using Xabe . FFmpeg ;
10
10
11
11
namespace AI . Labs . Module . BusinessObjects . FilterComplexScripts
12
- {
13
- public enum FontAlignment
12
+ {
13
+ // 枚举定义
14
+ public enum TextAlignment
14
15
{
15
- TopLeft = 1 ,
16
- TopCenter ,
17
- TopRight ,
18
- CenterLeft ,
19
- Center ,
20
- CenterRight ,
21
- BottomLeft ,
22
- BottomCenter ,
23
- BottomRight
16
+ BottomLeft = 1 ,
17
+ BottomCenter = 2 ,
18
+ BottomRight = 3 ,
19
+ MiddleLeft = 4 ,
20
+ MiddleCenter = 5 ,
21
+ MiddleRight = 6 ,
22
+ TopLeft = 7 ,
23
+ TopCenter = 8 ,
24
+ TopRight = 9
25
+ }
26
+
27
+ public enum BorderStyle
28
+ {
29
+ Normal = 1 ,
30
+ NoBorderShadow = 3
24
31
}
25
32
public class VideoSubtitleOption
26
33
{
27
34
public string SrtFileName { get ; set ; }
28
35
public int ? FontSize { get ; set ; }
29
- public string FontName { get ; set ; } = "微软雅黑" ;
30
- public string PrimaryColour { get ; set ; }
31
- public string SecondaryColour { get ; set ; }
32
- public string TertiaryColour { get ; set ; }
33
- public string BackColour { get ; set ; }
34
- public string OutlineColour { get ; set ; }
35
- public int ? OutlineThickness { get ; set ; }
36
- public FontAlignment ? Alignment { get ; set ; }
36
+ public string FontName { get ; set ; }
37
+ public string PrimaryColor { get ; set ; }
38
+ public string SecondaryColor { get ; set ; }
39
+ public string OutlineColor { get ; set ; }
40
+ public string BackColor { get ; set ; }
41
+ public bool ? Bold { get ; set ; }
42
+ public bool ? Italic { get ; set ; }
43
+ public bool ? Underline { get ; set ; }
44
+ public bool ? StrikeOut { get ; set ; }
45
+ public int ? Outline { get ; set ; }
46
+ public int ? Shadow { get ; set ; }
37
47
public int ? MarginL { get ; set ; }
38
48
public int ? MarginR { get ; set ; }
39
49
public int ? MarginV { get ; set ; }
40
-
50
+ public TextAlignment ? Alignment { get ; set ; }
51
+ public BorderStyle ? BorderStyle { get ; set ; }
41
52
public string GetStyle ( )
42
53
{
43
54
var styleOptions = new List < string > ( ) ;
@@ -48,44 +59,124 @@ public string GetStyle()
48
59
if ( ! string . IsNullOrEmpty ( FontName ) )
49
60
styleOptions . Add ( $ "Fontname={ FontName } ") ;
50
61
51
- if ( ! string . IsNullOrEmpty ( PrimaryColour ) )
52
- styleOptions . Add ( $ "PrimaryColour={ PrimaryColour } ") ;
53
-
54
- if ( ! string . IsNullOrEmpty ( SecondaryColour ) )
55
- styleOptions . Add ( $ "SecondaryColour={ SecondaryColour } ") ;
56
-
57
- if ( ! string . IsNullOrEmpty ( TertiaryColour ) )
58
- styleOptions . Add ( $ "TertiaryColour={ TertiaryColour } ") ;
59
-
60
- if ( ! string . IsNullOrEmpty ( BackColour ) )
61
- styleOptions . Add ( $ "BackColour={ BackColour } ") ;
62
-
63
- if ( ! string . IsNullOrEmpty ( OutlineColour ) )
64
- styleOptions . Add ( $ "OutlineColour={ OutlineColour } ") ;
65
-
66
- if ( OutlineThickness . HasValue )
67
- styleOptions . Add ( $ "OutlineThickness={ OutlineThickness . Value } ") ;
68
-
69
- if ( Alignment . HasValue )
70
- styleOptions . Add ( $ "Alignment={ ( int ) Alignment . Value } ") ;
71
-
62
+ if ( ! string . IsNullOrEmpty ( PrimaryColor ) )
63
+ styleOptions . Add ( $ "PrimaryColour={ PrimaryColor } ") ;
64
+ if ( ! string . IsNullOrEmpty ( SecondaryColor ) )
65
+ styleOptions . Add ( $ "SecondaryColour={ SecondaryColor } ") ;
66
+ if ( ! string . IsNullOrEmpty ( OutlineColor ) )
67
+ styleOptions . Add ( $ "OutlineColour={ OutlineColor } ") ;
68
+ if ( ! string . IsNullOrEmpty ( BackColor ) )
69
+ styleOptions . Add ( $ "BackColour={ BackColor } ") ;
70
+ if ( Bold . HasValue )
71
+ styleOptions . Add ( $ "Bold={ ( Bold . Value ? - 1 : 0 ) } ") ;
72
+ if ( Italic . HasValue )
73
+ styleOptions . Add ( $ "Italic={ ( Italic . Value ? - 1 : 0 ) } ") ;
74
+ if ( Underline . HasValue )
75
+ styleOptions . Add ( $ "Underline={ ( Underline . Value ? - 1 : 0 ) } ") ;
76
+ if ( StrikeOut . HasValue )
77
+ styleOptions . Add ( $ "StrikeOut={ ( StrikeOut . Value ? - 1 : 0 ) } ") ;
78
+ if ( Outline . HasValue )
79
+ styleOptions . Add ( $ "Outline={ Outline . Value } ") ;
80
+ if ( Shadow . HasValue )
81
+ styleOptions . Add ( $ "Shadow={ Shadow . Value } ") ;
72
82
if ( MarginL . HasValue )
73
83
styleOptions . Add ( $ "MarginL={ MarginL . Value } ") ;
74
-
75
84
if ( MarginR . HasValue )
76
85
styleOptions . Add ( $ "MarginR={ MarginR . Value } ") ;
77
-
78
86
if ( MarginV . HasValue )
79
87
styleOptions . Add ( $ "MarginV={ MarginV . Value } ") ;
88
+ if ( Alignment . HasValue )
89
+ styleOptions . Add ( $ "Alignment={ ( int ) Alignment . Value } ") ;
90
+ if ( BorderStyle . HasValue )
91
+ styleOptions . Add ( $ "BorderStyle={ ( int ) BorderStyle . Value } ") ;
80
92
81
93
return string . Join ( "," , styleOptions ) ;
82
94
}
83
95
84
96
public string GetScript ( )
85
97
{
98
+ // Assuming DrawTextOption.FixText is a method to sanitize SrtFileName
86
99
return $ "subtitles='{ DrawTextOption . FixText ( SrtFileName ) } ':force_style='{ GetStyle ( ) } '";
87
100
}
88
101
}
102
+
103
+
104
+ //public enum FontAlignment
105
+ //{
106
+ // TopLeft = 1,
107
+ // TopCenter,
108
+ // TopRight,
109
+ // CenterLeft,
110
+ // Center,
111
+ // CenterRight,
112
+ // BottomLeft,
113
+ // BottomCenter,
114
+ // BottomRight
115
+ //}
116
+ //public class VideoSubtitleOption
117
+ //{
118
+ // public string SrtFileName { get; set; }
119
+ // public int? FontSize { get; set; }
120
+ // public string FontName { get; set; } = "微软雅黑";
121
+ // public string PrimaryColour { get; set; }
122
+ // public string SecondaryColour { get; set; }
123
+ // public string TertiaryColour { get; set; }
124
+ // public string BackColour { get; set; }
125
+ // public string OutlineColour { get; set; }
126
+ // public int? OutlineThickness { get; set; }
127
+ // public FontAlignment? Alignment { get; set; }
128
+ // public int? MarginL { get; set; }
129
+ // public int? MarginR { get; set; }
130
+ // public int? MarginV { get; set; }
131
+
132
+ // public string GetStyle()
133
+ // {
134
+ // var styleOptions = new List<string>();
135
+
136
+ // if (FontSize.HasValue)
137
+ // styleOptions.Add($"Fontsize={FontSize.Value}");
138
+
139
+ // if (!string.IsNullOrEmpty(FontName))
140
+ // styleOptions.Add($"Fontname={FontName}");
141
+
142
+ // if (!string.IsNullOrEmpty(PrimaryColour))
143
+ // styleOptions.Add($"PrimaryColour={PrimaryColour}");
144
+
145
+ // if (!string.IsNullOrEmpty(SecondaryColour))
146
+ // styleOptions.Add($"SecondaryColour={SecondaryColour}");
147
+
148
+ // if (!string.IsNullOrEmpty(TertiaryColour))
149
+ // styleOptions.Add($"TertiaryColour={TertiaryColour}");
150
+
151
+ // if (!string.IsNullOrEmpty(BackColour))
152
+ // styleOptions.Add($"BackColour={BackColour}");
153
+
154
+ // if (!string.IsNullOrEmpty(OutlineColour))
155
+ // styleOptions.Add($"OutlineColour={OutlineColour}");
156
+
157
+ // if (OutlineThickness.HasValue)
158
+ // styleOptions.Add($"OutlineThickness={OutlineThickness.Value}");
159
+
160
+ // if (Alignment.HasValue)
161
+ // styleOptions.Add($"Alignment={(int)Alignment.Value}");
162
+
163
+ // if (MarginL.HasValue)
164
+ // styleOptions.Add($"MarginL={MarginL.Value}");
165
+
166
+ // if (MarginR.HasValue)
167
+ // styleOptions.Add($"MarginR={MarginR.Value}");
168
+
169
+ // if (MarginV.HasValue)
170
+ // styleOptions.Add($"MarginV={MarginV.Value}");
171
+
172
+ // return string.Join(",", styleOptions);
173
+ // }
174
+
175
+ // public string GetScript()
176
+ // {
177
+ // return $"subtitles='{DrawTextOption.FixText(SrtFileName)}':force_style='{GetStyle()}'";
178
+ // }
179
+ //}
89
180
}
90
181
91
182
//5.Style Lines, [v4 + Styles] section
0 commit comments