1 Star 1 Fork 0

m7s/plugin-record

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
raw.go 957 Bytes
一键复制 编辑 原始数据 按行查看 历史
langhuihui 提交于 2022-06-20 12:56 +08:00 . 适配引擎4.3.0变化
package record
import (
"path/filepath"
"strconv"
"time"
. "m7s.live/engine/v4"
"m7s.live/engine/v4/codec"
"m7s.live/engine/v4/track"
)
type RawRecorder struct {
Recorder
}
func (r *RawRecorder) OnEvent(event any) {
r.Recorder.OnEvent(event)
switch v := event.(type) {
case *RawRecorder:
go r.Start()
case *track.Video:
if r.Ext == "." {
if v.CodecID == codec.CodecID_H264 {
r.Ext = ".h264"
} else {
r.Ext = ".h265"
}
}
case VideoDeConf:
annexB := v.GetAnnexB()
annexB.WriteTo(r)
case *VideoFrame:
if r.Fragment != 0 && r.newFile {
r.newFile = false
r.Close()
if file, err := r.CreateFileFn(filepath.Join(r.Stream.Path, strconv.FormatInt(time.Now().Unix(), 10)+r.Ext), false); err == nil {
r.SetIO(file)
if r.Video.Track != nil {
annexB := VideoDeConf(r.Video.Track.DecoderConfiguration).GetAnnexB()
annexB.WriteTo(r)
}
}
}
annexB := v.GetAnnexB()
annexB.WriteTo(r)
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/m7s/plugin-record.git
git@gitee.com:m7s/plugin-record.git
m7s
plugin-record
plugin-record
v4

搜索帮助