Skip to content

Commit b6b1f4a

Browse files
committed
testing
1 parent f6346a0 commit b6b1f4a

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

format/nvr/muxer.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ type Muxer struct {
4747
pstart, pend time.Duration
4848
started bool
4949
serverID, streamName, channelName, streamID, channelID, hostLong, hostShort string
50-
handleFileChange func(string, string, int64, time.Time, time.Time, time.Duration)
50+
handleFileChange func(bool, string, string, int64, time.Time, time.Time, time.Duration)
5151
}
5252

5353
type Gof struct {
@@ -75,7 +75,7 @@ func init() {
7575

7676
}
7777

78-
func NewMuxer(serverID, streamName, channelName, streamID, channelID string, mpoint []string, patch, format string, limit int, c func(string, string, int64, time.Time, time.Time, time.Duration)) (m *Muxer, err error) {
78+
func NewMuxer(serverID, streamName, channelName, streamID, channelID string, mpoint []string, patch, format string, limit int, c func(bool, string, string, int64, time.Time, time.Time, time.Duration)) (m *Muxer, err error) {
7979
hostLong, _ := os.Hostname()
8080
var hostShort string
8181
if p, _, ok := strings.Cut(hostLong, "."); ok {
@@ -218,9 +218,20 @@ func (m *Muxer) OpenMP4() (err error) {
218218
if err = os.MkdirAll(filepath.Dir(d), 0755); err != nil {
219219
return
220220
}
221-
if m.d, err = os.Create(filepath.Join(filepath.Dir(d), fmt.Sprintf("tmp_%s_%d.mp4", uuid.New(), time.Now().Unix()))); err != nil {
221+
name := filepath.Join(filepath.Dir(d), fmt.Sprintf("tmp_%s_%d.mp4", uuid.New(), time.Now().Unix()))
222+
if m.d, err = os.Create(name); err != nil {
222223
return
223224
}
225+
m.handleFileChange(
226+
true,
227+
m.Codecs(),
228+
name,
229+
0,
230+
m.start,
231+
m.end,
232+
m.dur,
233+
)
234+
224235
m.muxer = mp4.NewMuxer(m.d)
225236
m.muxer.NegativeTsMakeZero = true
226237
if err = m.muxer.WriteHeader(m.gof.Streams); err != nil {
@@ -329,7 +340,7 @@ func (m *Muxer) filePatch() (string, error) {
329340
func (m *Muxer) Codecs() string {
330341
var codecs []string
331342
for _, stream := range m.gof.Streams {
332-
codecs = append(codecs, stream.Type().String())
343+
codecs = append(codecs, strings.ToLower(stream.Type().String()))
333344
}
334345

335346
return strings.Join(codecs, ",")
@@ -356,6 +367,7 @@ func (m *Muxer) WriteTrailer() (err error) {
356367
size = fi.Size()
357368
}
358369
m.handleFileChange(
370+
false,
359371
m.Codecs(),
360372
filepath.Join(filepath.Dir(m.d.Name()), filepath.Base(p)),
361373
size,

0 commit comments

Comments
 (0)