mirror of
https://github.com/Monibuca/plugin-record.git
synced 2025-10-19 23:16:16 +08:00
fix: subscribe will block event bus
This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
subscribe:
|
subscribe:
|
||||||
submode: 1
|
submode: 1
|
||||||
|
internal: true
|
1
flv.go
1
flv.go
@@ -96,6 +96,7 @@ func (r *FLVRecorder) writeMetaData(file *os.File, duration int64) {
|
|||||||
defer func() {
|
defer func() {
|
||||||
tempFile.Close()
|
tempFile.Close()
|
||||||
os.Remove(tempFile.Name())
|
os.Remove(tempFile.Name())
|
||||||
|
r.Info("writeMetaData success")
|
||||||
}()
|
}()
|
||||||
_, err := tempFile.Write([]byte{'F', 'L', 'V', 0x01, flags, 0, 0, 0, 9, 0, 0, 0, 0})
|
_, err := tempFile.Write([]byte{'F', 'L', 'V', 0x01, flags, 0, 0, 0, 9, 0, 0, 0, 0})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
4
go.mod
4
go.mod
@@ -5,7 +5,7 @@ go 1.19
|
|||||||
require (
|
require (
|
||||||
github.com/edgeware/mp4ff v0.28.0
|
github.com/edgeware/mp4ff v0.28.0
|
||||||
go.uber.org/zap v1.23.0
|
go.uber.org/zap v1.23.0
|
||||||
m7s.live/engine/v4 v4.12.0
|
m7s.live/engine/v4 v4.12.6
|
||||||
m7s.live/plugin/hls/v4 v4.0.0-20220619163635-447976e65ab9
|
m7s.live/plugin/hls/v4 v4.0.0-20220619163635-447976e65ab9
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ require (
|
|||||||
github.com/shirou/gopsutil/v3 v3.22.10 // indirect
|
github.com/shirou/gopsutil/v3 v3.22.10 // indirect
|
||||||
github.com/tklauser/go-sysconf v0.3.11 // indirect
|
github.com/tklauser/go-sysconf v0.3.11 // indirect
|
||||||
github.com/tklauser/numcpus v0.6.0 // indirect
|
github.com/tklauser/numcpus v0.6.0 // indirect
|
||||||
github.com/yapingcat/gomedia v0.0.0-20230222121919-c67df405bf33 // indirect
|
github.com/yapingcat/gomedia v0.0.0-20230426092936-387031404274 // indirect
|
||||||
github.com/yusufpapurcu/wmi v1.2.2 // indirect
|
github.com/yusufpapurcu/wmi v1.2.2 // indirect
|
||||||
go.uber.org/atomic v1.10.0 // indirect
|
go.uber.org/atomic v1.10.0 // indirect
|
||||||
go.uber.org/multierr v1.8.0 // indirect
|
go.uber.org/multierr v1.8.0 // indirect
|
||||||
|
8
go.sum
8
go.sum
@@ -151,8 +151,8 @@ github.com/tklauser/go-sysconf v0.3.11/go.mod h1:GqXfhXY3kiPa0nAXPDIQIWzJbMCB7Am
|
|||||||
github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ=
|
github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ=
|
||||||
github.com/tklauser/numcpus v0.6.0 h1:kebhY2Qt+3U6RNK7UqpYNA+tJ23IBEGKkB7JQBfDYms=
|
github.com/tklauser/numcpus v0.6.0 h1:kebhY2Qt+3U6RNK7UqpYNA+tJ23IBEGKkB7JQBfDYms=
|
||||||
github.com/tklauser/numcpus v0.6.0/go.mod h1:FEZLMke0lhOUG6w2JadTzp0a+Nl8PF/GFkQ5UVIcaL4=
|
github.com/tklauser/numcpus v0.6.0/go.mod h1:FEZLMke0lhOUG6w2JadTzp0a+Nl8PF/GFkQ5UVIcaL4=
|
||||||
github.com/yapingcat/gomedia v0.0.0-20230222121919-c67df405bf33 h1:uyZY++dluUg7iTSsNzuOVln/mC2U2KXwgKLfKLCJ74Y=
|
github.com/yapingcat/gomedia v0.0.0-20230426092936-387031404274 h1:cj4I+bvWX9I+Hg6tnZ7DAiOVxzhyLhdvYVKp+WpM/2c=
|
||||||
github.com/yapingcat/gomedia v0.0.0-20230222121919-c67df405bf33/go.mod h1:WSZ59bidJOO40JSJmLqlkBJrjZCtjbKKkygEMfzY/kc=
|
github.com/yapingcat/gomedia v0.0.0-20230426092936-387031404274/go.mod h1:WSZ59bidJOO40JSJmLqlkBJrjZCtjbKKkygEMfzY/kc=
|
||||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
@@ -281,7 +281,7 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
|
|||||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
m7s.live/engine/v4 v4.12.0 h1:CRPbJ0jhHVZArc5mvV7e6Seb4Ye816kGzs3FOVKnfHw=
|
m7s.live/engine/v4 v4.12.6 h1:JWUwxOVHzL9wh8JbWUtZaDsRBXzyAzPI+4UEMGftsU0=
|
||||||
m7s.live/engine/v4 v4.12.0/go.mod h1:AiJPBwdA77DM3fymlcH2qYPR8ivL6ib9UVLm1Rft/to=
|
m7s.live/engine/v4 v4.12.6/go.mod h1:LoALBfV5rmsz5TJQr6cmLxM33mfUE5BKBq/sMtXOVlc=
|
||||||
m7s.live/plugin/hls/v4 v4.0.0-20220619163635-447976e65ab9 h1:EcB8awppfwza+s4ECjUr3xLTtl9BgJcZ12EgfE/L2YA=
|
m7s.live/plugin/hls/v4 v4.0.0-20220619163635-447976e65ab9 h1:EcB8awppfwza+s4ECjUr3xLTtl9BgJcZ12EgfE/L2YA=
|
||||||
m7s.live/plugin/hls/v4 v4.0.0-20220619163635-447976e65ab9/go.mod h1:Qn4dDz5xlyBJwO+eZ3w8CUQ8Hl6KN1nmv0a3IsOjJvw=
|
m7s.live/plugin/hls/v4 v4.0.0-20220619163635-447976e65ab9/go.mod h1:Qn4dDz5xlyBJwO+eZ3w8CUQ8Hl6KN1nmv0a3IsOjJvw=
|
||||||
|
16
main.go
16
main.go
@@ -65,29 +65,23 @@ func (conf *RecordConfig) OnEvent(event any) {
|
|||||||
streamPath := v.Target.Path
|
streamPath := v.Target.Path
|
||||||
if conf.Flv.NeedRecord(streamPath) {
|
if conf.Flv.NeedRecord(streamPath) {
|
||||||
var flv FLVRecorder
|
var flv FLVRecorder
|
||||||
flv.IsInternal = true
|
|
||||||
if flv.Start(streamPath) == nil {
|
|
||||||
conf.Flv.recording[streamPath] = &flv
|
conf.Flv.recording[streamPath] = &flv
|
||||||
}
|
go flv.Start(streamPath)
|
||||||
}
|
}
|
||||||
if conf.Mp4.NeedRecord(streamPath) {
|
if conf.Mp4.NeedRecord(streamPath) {
|
||||||
if recoder := NewMP4Recorder(); recoder.Start(streamPath) == nil {
|
recoder := NewMP4Recorder()
|
||||||
conf.Mp4.recording[streamPath] = recoder
|
conf.Mp4.recording[streamPath] = recoder
|
||||||
}
|
go recoder.Start(streamPath)
|
||||||
}
|
}
|
||||||
if conf.Hls.NeedRecord(streamPath) {
|
if conf.Hls.NeedRecord(streamPath) {
|
||||||
var hls HLSRecorder
|
var hls HLSRecorder
|
||||||
hls.IsInternal = true
|
|
||||||
if hls.Start(streamPath) == nil {
|
|
||||||
conf.Hls.recording[streamPath] = &hls
|
conf.Hls.recording[streamPath] = &hls
|
||||||
}
|
go hls.Start(streamPath)
|
||||||
}
|
}
|
||||||
if conf.Raw.NeedRecord(streamPath) {
|
if conf.Raw.NeedRecord(streamPath) {
|
||||||
var raw RawRecorder
|
var raw RawRecorder
|
||||||
raw.IsInternal = true
|
|
||||||
if raw.Start(streamPath) == nil {
|
|
||||||
conf.Raw.recording[streamPath] = &raw
|
conf.Raw.recording[streamPath] = &raw
|
||||||
}
|
go raw.Start(streamPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
3
mp4.go
3
mp4.go
@@ -41,7 +41,7 @@ func (m *mediaContext) push(recoder *MP4Recorder, dt uint32, dur uint32, data []
|
|||||||
|
|
||||||
type MP4Recorder struct {
|
type MP4Recorder struct {
|
||||||
Recorder
|
Recorder
|
||||||
*mp4.InitSegment `json:"-"`
|
*mp4.InitSegment `json:"-" yaml:"-"`
|
||||||
video mediaContext
|
video mediaContext
|
||||||
audio mediaContext
|
audio mediaContext
|
||||||
seqNumber uint32
|
seqNumber uint32
|
||||||
@@ -52,7 +52,6 @@ func NewMP4Recorder() *MP4Recorder {
|
|||||||
r := &MP4Recorder{
|
r := &MP4Recorder{
|
||||||
InitSegment: mp4.CreateEmptyInit(),
|
InitSegment: mp4.CreateEmptyInit(),
|
||||||
}
|
}
|
||||||
r.IsInternal = true
|
|
||||||
r.Moov.Mvhd.NextTrackID = 1
|
r.Moov.Mvhd.NextTrackID = 1
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
@@ -52,23 +52,19 @@ func (conf *RecordConfig) API_start(w http.ResponseWriter, r *http.Request) {
|
|||||||
fallthrough
|
fallthrough
|
||||||
case "flv":
|
case "flv":
|
||||||
var flvRecoder FLVRecorder
|
var flvRecoder FLVRecorder
|
||||||
flvRecoder.IsInternal = true
|
|
||||||
flvRecoder.append = query.Get("append") != ""
|
flvRecoder.append = query.Get("append") != ""
|
||||||
err = flvRecoder.Start(streamPath)
|
err = flvRecoder.Start(streamPath)
|
||||||
id = flvRecoder.ID
|
id = flvRecoder.ID
|
||||||
case "mp4":
|
case "mp4":
|
||||||
recorder := NewMP4Recorder()
|
recorder := NewMP4Recorder()
|
||||||
recorder.IsInternal = true
|
|
||||||
err = recorder.Start(streamPath)
|
err = recorder.Start(streamPath)
|
||||||
id = recorder.ID
|
id = recorder.ID
|
||||||
case "hls":
|
case "hls":
|
||||||
var recorder HLSRecorder
|
var recorder HLSRecorder
|
||||||
recorder.IsInternal = true
|
|
||||||
err = recorder.Start(streamPath)
|
err = recorder.Start(streamPath)
|
||||||
id = recorder.ID
|
id = recorder.ID
|
||||||
case "raw":
|
case "raw":
|
||||||
var recorder RawRecorder
|
var recorder RawRecorder
|
||||||
recorder.IsInternal = true
|
|
||||||
recorder.append = query.Get("append") != ""
|
recorder.append = query.Get("append") != ""
|
||||||
err = recorder.Start(streamPath)
|
err = recorder.Start(streamPath)
|
||||||
id = recorder.ID
|
id = recorder.ID
|
||||||
|
@@ -11,7 +11,7 @@ import (
|
|||||||
type Recorder struct {
|
type Recorder struct {
|
||||||
Subscriber
|
Subscriber
|
||||||
SkipTS uint32
|
SkipTS uint32
|
||||||
*Record `json:"-"`
|
*Record `json:"-" yaml:"-"`
|
||||||
newFile bool // 创建了新的文件
|
newFile bool // 创建了新的文件
|
||||||
append bool // 是否追加模式
|
append bool // 是否追加模式
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user