Skip to content

Commit 4949d44

Browse files
author
qianjianeng
committed
增加跑马灯
1 parent 23ff9eb commit 4949d44

File tree

7 files changed

+77
-22
lines changed

7 files changed

+77
-22
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* [x] [7. 去除水印]
1919
* [x] [8. 调整视频分辨率]
2020
* [x] [9. 添加文字水印]
21+
* [x] [9_1. 添加跑马灯文字水印]
2122
* [x] [10. 添加图片水印]
2223
* [x] [11. 倍速播放(加速减速)]
2324
* [x] [12. 添加片头]
@@ -26,7 +27,6 @@
2627
* TODO
2728
* [ ] [1. 去掉视频原有的配音]
2829
* [ ] [2. 添加自己的配音]
29-
* [ ] [3. 跑马灯水印]
3030
* [ ] [4. 添加字幕]
3131

3232

@@ -100,6 +100,9 @@ cd mac 进入到mac 文件夹下
100100
#### 1.3
101101
链接:https://pan.baidu.com/s/1n0VdfU7vW8q_jrPMK1VrqQ 密码:x4dn
102102

103+
#### 1.4
104+
链接:https://pan.baidu.com/s/1bbBdaYNm5XsBjuZ_Vvb5Og 密码:yf0d
105+
103106
## 版本更新记录
104107

105108
#### 1.0
@@ -128,6 +131,10 @@ windows `./vm.exe -f config1.toml`
128131
#### 1.3
129132
* 增加倍速播放,可以将视频加速或者减速
130133

134+
#### 1.4
135+
* 文字水印,图片水印增加4种样式,一共9种
136+
* 增加文字水印跑马灯效果
137+
131138
## 其他说明
132139

133140
自媒体创作者可以加我微信,备注自媒体,拉你进交流群。

config.toml

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,29 @@ videoPath = "./video"
99
system = 0
1010
## 1. 视频格式转换
1111
[format]
12-
switch = true
12+
switch = false
1313
form = "mp4"
1414

1515
## 2. 帧率设置
1616
## eg: +5 在原来的基础上+5 -5 在原来的基础上-5 20 修改为20
1717
[frameRate]
18-
switch = true
18+
switch = false
1919
value = "+5"
2020

2121
## 3. 码率设置
2222
## eg: +5 在原来的基础上+5 -5 在原来的基础上-5 20 修改为20
2323
[bitRate]
24-
switch = true
24+
switch = false
2525
value = "+5"
2626

2727
## 4. 减掉视频前几秒
2828
[cutFront]
29-
switch = true
29+
switch = false
3030
value = 2
3131

3232
## 5. 减掉视频最后几秒
3333
[cutBack]
34-
switch = true
34+
switch = false
3535
value = 2
3636

3737
# 6. 视频剪裁
@@ -48,7 +48,7 @@ system = 0
4848

4949
## 7. 去除水印
5050
[clearWater]
51-
switch = true
51+
switch = false
5252
x = 10
5353
y = 10
5454
w = 100
@@ -62,39 +62,51 @@ system = 0
6262
h = 1920
6363

6464
## 9. 文字水印
65-
## eg: +5 在原来的基础上+5 -5 在原来的基础上-5 20 修改为20
6665
[waterText]
6766
switch = true
6867
content = "测试文字"
6968
path = "./source/simsun.ttc"
7069
size = 50
7170
color = "black"
7271
alpha = 0.8
73-
style = 1
72+
style = 8
7473
sp1 = 50
7574
sp2 = 100
7675

76+
## 9.1 滚动文字
77+
# isTop 顶部还是底部 sp 距离顶部或者底部的距离
78+
# leftToRight 是否从坐到右
79+
[runWaterText]
80+
switch = false
81+
content = "测试文字"
82+
path = "./source/simsun.ttc"
83+
size = 50
84+
color = "black"
85+
isTop = true
86+
leftToRight = true
87+
sp = 50
88+
7789

7890
## 10. 图片水印
7991
[waterImage]
80-
switch = true
92+
switch = false
8193
path = "./source/item.jpg"
8294
style = 2
8395
sp1 = 50
8496
sp2 = 100
8597

8698
# 11. 倍速播放(取值范围 0.5~2)0.5 速度减慢一倍,2 速度加快一倍,1 速度不变
8799
[speed]
88-
switch = true
100+
switch = false
89101
v = "2"
90102

91103
## 12. 片头
92104
[filmTitle]
93-
switch = true
105+
switch = false
94106
path = "./source/film.mp4"
95107

96108
## 13. 片尾
97109
[filmEnd]
98-
switch = true
110+
switch = false
99111
path = "./source/film.mp4"
100112

deal/config/config.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ type Config struct {
2020
ClearWater ClearWater
2121
Resolution Resolution
2222
WaterText WaterText
23+
RunWaterText RunWaterText `toml:"RunWaterText"`
2324
WaterImage WaterImage
2425
Speed Speed
2526
FilmTitle FilmTitle
@@ -89,6 +90,17 @@ type WaterText struct {
8990
Sp2 int
9091
}
9192

93+
type RunWaterText struct {
94+
Switch bool
95+
Content string
96+
Path string
97+
Size int
98+
Color string
99+
IsTop bool `toml:"isTop"`
100+
LeftToRight bool `toml:"leftToRight"`
101+
Sp int
102+
}
103+
92104
type WaterImage struct {
93105
Switch bool
94106
Path string

deal/factory/factory.go

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,17 @@ func deal(f string, con *config.Config)string {
136136
f = ffmpeg.CropVideo(fCmd,f,con.Crop.Start,con.Crop.Duration,con.Crop.X,con.Crop.Y,con.Crop.W,con.Crop.H)
137137
}
138138

139-
// 6. clear water
139+
// 7. clear water
140140
if con.ClearWater.Switch {
141141
f = ffmpeg.ClearWater(fCmd,f,con.ClearWater.X,con.ClearWater.Y,con.ClearWater.W,con.ClearWater.H)
142142
}
143143

144-
//7. Resolution
144+
//8. Resolution
145145
if con.Resolution.Switch {
146146
f = ffmpeg.UpdateResolution(fCmd, f, con.Resolution.W, con.Resolution.H)
147147
}
148148

149-
//8. water text
149+
//9. water text
150150
if con.WaterText.Switch {
151151
info, err := ffmpeg.GetVideoInfo(fCmd, f)
152152
if err != nil {
@@ -166,7 +166,25 @@ func deal(f string, con *config.Config)string {
166166
)
167167
}
168168

169-
//9. water image
169+
// 9.1 runtext
170+
if con.RunWaterText.Switch {
171+
info, err := ffmpeg.GetVideoInfo(fCmd, f)
172+
if err != nil {
173+
return f
174+
}
175+
f = info.AddScrollTextWater(
176+
fCmd,
177+
f,
178+
con.RunWaterText.Path,
179+
con.RunWaterText.Content,
180+
con.RunWaterText.Color,
181+
con.RunWaterText.Size,
182+
con.RunWaterText.IsTop,
183+
con.RunWaterText.LeftToRight,
184+
con.RunWaterText.Sp,
185+
)
186+
}
187+
//10. water image
170188
if con.WaterImage.Switch {
171189
info, err := ffmpeg.GetVideoInfo(fCmd, f)
172190
if err != nil {

deal/factory/util.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ func GetFCmd(system int) string {
1414
system = info.PlatForm
1515
}
1616
if system == sys.MacOS {
17-
return "./source/mac/ffmpeg"
17+
return "./source/mac/tool"
1818
} else if system == sys.Win64{
19-
return "./source/win/64/ffmpeg.exe"
19+
return "./source/win/64/tool.exe"
2020
} else if system == sys.Win32 {
21-
return "./source/win/32/ffmpeg.exe"
21+
return "./source/win/32/tool.exe"
2222
}
2323

2424
fmt.Println("系统类型无法识别,请在配置中指定:1:mac 3: win32 4:win64")

main.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"time"
1212
)
1313
var conFile = flag.String("f", "", "config file")
14+
var videoPath = flag.String("v", "", "config file")
1415
func main() {
1516
Run()
1617
}
@@ -23,10 +24,14 @@ func Run() {
2324
return
2425
}
2526

26-
2727
con := config.ReadConfig(*conFile)
2828
fmt.Println(con)
2929

30+
if len(*videoPath) > 0 {
31+
con.VideoPath = *videoPath
32+
fmt.Println(*videoPath)
33+
}
34+
3035
factory.DoFactory(con)
3136

3237
}
@@ -84,7 +89,8 @@ type Message struct {
8489
func check() bool {
8590

8691
url := "https://api.github.com/repos/suifengqjn/videoWater/issues"
87-
resp, err := http.Get(url)
92+
client := http.Client{Timeout:time.Second*20}
93+
resp, err := client.Get(url)
8894
if err != nil {
8995
fmt.Println("请检查网络")
9096
return false
File renamed without changes.

0 commit comments

Comments
 (0)