Eanfs v4 (#41)

* [feature] 支持录制完成后上传到Minio

* change module id

* Update mod name

* reset go.mod

* Update for minio uploading

* Update for log

* [feature] support all Recorder

* Update

* Merge branch 'v4' into githubv4

* v4:
  git commit for minio

* fix error

* Update

* Update

* Update for support max Duration

* Update v4.6.5

* Update for chang Config name

* [refactor] update for recording duration

* Update for remove orgion file

* Update mod

* Update

* fix: close mp4 record error

* Update readme

* Fix file not upload Successfully

* feat(recording): 支持录制检查回调

* feat:增加数据库录制检查

* Update 录制文件没有写入结束标志

* 更新依赖包

* fix(record): 自动删除的录像文件。

* Update for sqllite to db error
This commit is contained in:
eanfs
2025-06-20 16:33:44 +08:00
committed by GitHub
parent 671097a436
commit df6486a022
17 changed files with 424 additions and 89 deletions

View File

@@ -38,6 +38,7 @@ type IRecorder interface {
type Recorder struct {
Subscriber
Storage StorageConfig
SkipTS uint32
Record `json:"-" yaml:"-"`
File FileWr `json:"-" yaml:"-"`
@@ -67,6 +68,7 @@ func (r *Recorder) CreateFile() (f FileWr, err error) {
logFields = append(logFields, zap.Error(err))
r.Error("create file", logFields...)
}
r.SaveToDB()
return
}
@@ -121,12 +123,21 @@ func (r *Recorder) cut(absTime uint32) {
}
}
func (r *Recorder) stopByDuration(absTime uint32) {
if ts := absTime - r.SkipTS; time.Duration(ts)*time.Millisecond >= r.Duration {
r.Info("stop recorder by duration")
r.SkipTS = absTime
r.Stop()
}
}
// func (r *Recorder) Stop(reason ...zap.Field) {
// r.Close()
// r.Subscriber.Stop(reason...)
// }
func (r *Recorder) OnEvent(event any) {
// r.Debug("🟡->🟡->🟡 Recorder OnEvent: ", zap.String("event", reflect.TypeOf(event).String()))
switch v := event.(type) {
case IRecorder:
if file, err := r.Spesific.(IRecorder).CreateFile(); err == nil {
@@ -156,6 +167,9 @@ func (r *Recorder) OnEvent(event any) {
if r.Fragment > 0 && v.IFrame {
r.cut(v.AbsTime)
}
if r.Duration > 0 && v.IFrame {
r.stopByDuration(v.AbsTime)
}
default:
r.Subscriber.OnEvent(event)
}