feat: transcode log by day

This commit is contained in:
langhuihui
2024-11-08 14:11:53 +08:00
parent e024c5eea5
commit 290094b355
2 changed files with 18 additions and 18 deletions

34
api.go
View File

@@ -323,26 +323,26 @@ func (s *Server) VideoTrackSnap(ctx context.Context, req *pb.StreamSnapRequest)
res.Reader[sub.ID] = sub.VideoReader.Value.Sequence res.Reader[sub.ID] = sub.VideoReader.Value.Sequence
} }
pub.VideoTrack.Ring.Do(func(v *pkg.AVFrame) { pub.VideoTrack.Ring.Do(func(v *pkg.AVFrame) {
if v.TryRLock() { //if v.TryRLock() {
if len(v.Wraps) > 0 { if len(v.Wraps) > 0 {
var snap pb.TrackSnapShot var snap pb.TrackSnapShot
snap.Sequence = v.Sequence snap.Sequence = v.Sequence
snap.Timestamp = uint32(v.Timestamp / time.Millisecond) snap.Timestamp = uint32(v.Timestamp / time.Millisecond)
snap.WriteTime = timestamppb.New(v.WriteTime) snap.WriteTime = timestamppb.New(v.WriteTime)
snap.Wrap = make([]*pb.Wrap, len(v.Wraps)) snap.Wrap = make([]*pb.Wrap, len(v.Wraps))
snap.KeyFrame = v.IDR snap.KeyFrame = v.IDR
res.RingDataSize += uint32(v.Wraps[0].GetSize()) res.RingDataSize += uint32(v.Wraps[0].GetSize())
for i, wrap := range v.Wraps { for i, wrap := range v.Wraps {
snap.Wrap[i] = &pb.Wrap{ snap.Wrap[i] = &pb.Wrap{
Timestamp: uint32(wrap.GetTimestamp() / time.Millisecond), Timestamp: uint32(wrap.GetTimestamp() / time.Millisecond),
Size: uint32(wrap.GetSize()), Size: uint32(wrap.GetSize()),
Data: wrap.String(), Data: wrap.String(),
}
} }
res.Ring = append(res.Ring, &snap)
} }
v.RUnlock() res.Ring = append(res.Ring, &snap)
} }
//v.RUnlock()
//}
}) })
} else { } else {
err = pkg.ErrNotFound err = pkg.ErrNotFound

View File

@@ -143,7 +143,7 @@ func (t *Transformer) Start() (err error) {
t.SetDescription("cmd", args) t.SetDescription("cmd", args)
t.SetDescription("config", t.TransRule) t.SetDescription("config", t.TransRule)
//t.BufReader.Dump, err = os.OpenFile("dump.flv", os.O_CREATE|os.O_WRONLY, 0644) //t.BufReader.Dump, err = os.OpenFile("dump.flv", os.O_CREATE|os.O_WRONLY, 0644)
t.logFileName = fmt.Sprintf("logs/transcode_%s_%s.log", strings.ReplaceAll(t.TransformJob.StreamPath, "/", "_"), time.Now().Format("20060102150405")) t.logFileName = fmt.Sprintf("logs/transcode_%s_%s.log", strings.ReplaceAll(t.TransformJob.StreamPath, "/", "_"), time.Now().Format("20060102"))
t.ffmpeg = exec.CommandContext(t, "ffmpeg", args...) t.ffmpeg = exec.CommandContext(t, "ffmpeg", args...)
if t.logFileName != "" { if t.logFileName != "" {
t.SetDescription("log", t.logFileName) t.SetDescription("log", t.logFileName)