Skip to content

Commit

Permalink
Add retryCount to rtmp input log line for monitoring (#3380)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjh1 authored Feb 7, 2025
1 parent cdffc6d commit 61f6fb4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions media/rtmp2segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func (ms *MediaSegmenter) RunSegmentation(ctx context.Context, in string, segmen
processSegments(ctx, segmentHandler, outFilePattern, completionSignal)
}()

retryCount := 0
for {
err := backoff.Retry(func() error {
streamExists, err := ms.MediaMTXClient.StreamExists()
Expand All @@ -68,7 +69,7 @@ func (ms *MediaSegmenter) RunSegmentation(ctx context.Context, in string, segmen
clog.Errorf(ctx, "Stopping segmentation in=%s err=%s", in, err)
break
}
clog.Infof(ctx, "Starting segmentation. in=%s", in)
clog.Infof(ctx, "Starting segmentation. in=%s retryCount=%d", in, retryCount)
cmd := exec.CommandContext(procCtx, "ffmpeg",
"-i", in,
"-c:a", "copy",
Expand All @@ -81,8 +82,9 @@ func (ms *MediaSegmenter) RunSegmentation(ctx context.Context, in string, segmen
clog.Errorf(ctx, "Error receiving RTMP: %v", err)
break
}
clog.Infof(ctx, "Segmentation ffmpeg output: %s", output)
clog.Infof(ctx, "Segmentation stopped, will retry. retryCount=%d ffmpeg output: %s", retryCount, output)
time.Sleep(5 * time.Second)
retryCount++
}
completionSignal <- true
clog.Infof(ctx, "sent completion signal, now waiting")
Expand Down

0 comments on commit 61f6fb4

Please sign in to comment.