From 5169c4eb3a0336434fc99ce2c293d22583f7ccdd Mon Sep 17 00:00:00 2001 From: emranemran Date: Sun, 14 Jul 2024 10:56:36 -0700 Subject: [PATCH] clip: add more logging to debug failed clips Clips are failing reporting 'start time specified exceeds duration of manifest'. This may happen for webrtc streams where the clip request comes in but the segments and manifest hasn't been written yet to S3. I n this case, the start time would fall past the latest segment and this error case would be hit -- however, we have several retries for this exact scenario. Based on logs, there are 10 retries every 5 seconds in addition to 3 studio retries - this should be sufficient for the latest segments to be written to S3 and the clip request would eventually succeed. This is not happening so we're adding the additional logging to ensure latest manifests are being downloaded on retry attempts. --- clients/manifest.go | 2 ++ video/clip.go | 2 +- video/clip_test.go | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/clients/manifest.go b/clients/manifest.go index 99fa35ca..369fab5a 100644 --- a/clients/manifest.go +++ b/clients/manifest.go @@ -15,6 +15,7 @@ import ( "github.com/cenkalti/backoff/v4" "github.com/grafov/m3u8" + "github.com/livepeer/catalyst-api/log" "github.com/livepeer/catalyst-api/video" ) @@ -223,6 +224,7 @@ func ClipInputManifest(requestID, sourceURL, clipTargetUrl string, startTimeUnix if err != nil { return nil, fmt.Errorf("error clipping: failed to download original manifest: %w", err) } + log.Log(requestID, "Downloaded manifest to clip", "segments", origManifest.Count()) // Generate the absolute path URLS for segmens from the manifest's relative path // TODO: optimize later and only get absolute path URLs for the start/end segments diff --git a/video/clip.go b/video/clip.go index 7bd43d44..3aaf18e3 100644 --- a/video/clip.go +++ b/video/clip.go @@ -113,7 +113,7 @@ func ClipManifest(requestID string, manifest *m3u8.MediaPlaylist, startTime, end // Find the segment index that correlates with the specified startTime // but error out it exceeds the manifest's duration. if startTime > manifestDuration { - return nil, []ClipSegmentInfo{}, fmt.Errorf("error clipping: start time specified exceeds duration of manifest") + return nil, []ClipSegmentInfo{}, fmt.Errorf("error clipping: start time (%f) specified exceeds duration of manifest (%f)", startTime, manifestDuration) } else { clipStartSegmentInfo, err = getRelevantSegment(manifest.Segments, startTime, 0) if err != nil { diff --git a/video/clip_test.go b/video/clip_test.go index a27470a7..20a6c775 100644 --- a/video/clip_test.go +++ b/video/clip_test.go @@ -150,7 +150,7 @@ func TestClippingSucceedsWhenValidManifestIsUsed(t *testing.T) { // start exceeds the duration of playlist: ensure no segments are returned segs, _, err = ClipManifest("1234", plB, 30, 20.78) - require.ErrorContains(t, err, "start time specified exceeds duration of manifest") + require.ErrorContains(t, err, "exceeds duration of manifest") require.Equal(t, segs, []*m3u8.MediaSegment(nil)) // end exceeds the duration of playlist: ensure only 0.ts is returned