视频叠加

This commit is contained in:
banshan
2024-09-10 16:03:12 +08:00
parent 6ad3c8bddf
commit ac0b21e0ae
4 changed files with 34 additions and 4 deletions

View File

@@ -8,4 +8,8 @@ gb28181:
- udp::5060
onsub:
pull:
.* : $0
.* : $0
#rtsp:
# tcp:
# listenaddr: :10554

View File

@@ -1,9 +1,25 @@
global:
loglevel: debug
#rtsp:
# tcp:
# listenaddr: :10554
transcode:
onpub:
transform:
.+:
# .+:
# output:
# - target: rtmp://localhost/$0/h265
# conf: -loglevel debug -c:a aac -c:v hevc_videotoolbox
live/.*:
output:
- target: rtmp://localhost/$0/h265
conf: -loglevel debug -c:a aac -c:v hevc_videotoolbox
- target: rtmp://localhost/$0/h264
overlay: rtmp://localhost/overlay/test
# filter: drawtext=fontfile=/usr/share/fonts/truetype/noto/NotoSans-Regular.ttf:fontsize=24:fontcolor=white:box=1:boxcolor=black@0.5:boxborderw=5:x=(w-tw)/2:y=h-th-10:text='%{localtime\:%Y-%m-%d %H.%M.%S}'
filter: |
[1:v]crop=400:300:10:10[overlay];
[0:v][overlay]overlay=600:100[base];
[base]drawtext=fontfile=/usr/share/fonts/truetype/noto/NotoSans-Regular.ttf:fontsize=24:fontcolor=white:box=1:boxcolor=black@0.5:boxborderw=5:x=(w-tw)/2:y=h-th-10:text='%{localtime\:%Y-%m-%d %H.%M.%S}'[out]
conf: -loglevel debug -c:a copy -c:v h264

View File

@@ -62,6 +62,8 @@ type (
Target string `desc:"转码目标"` // 转码目标
StreamPath string
Conf any
Filter string `desc:"视频滤镜"`
Overlay string `desc:"视频叠加"`
}
}
OnPublish struct {

View File

@@ -99,6 +99,14 @@ func (t *Transformer) Start() (err error) {
}
}
t.To[i] = enc
if to.Overlay != "" {
args = append(args, "-i", to.Overlay)
}
if to.Filter != "" {
args = append(args, "-filter_complex", strings.ReplaceAll(to.Filter, "\n", ""))
args = append(args, "-map", "[out]")
args = append(args, "-map", "0:a")
}
args = append(args, strings.Fields(enc.Args)...)
var targetUrl *url.URL
targetUrl, err = url.Parse(to.Target)