Skip to content

Commit

Permalink
coordinator: disable mp4 generation if duration is 0 for any reason
Browse files Browse the repository at this point in the history
  • Loading branch information
emranemran committed Sep 13, 2023
1 parent b8dc66e commit a78b219
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pipeline/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,20 @@ func (c *Coordinator) StartUploadJob(p UploadJobPayload) {
log.AddContext(p.RequestID, "new_source_url", si.SourceFile)
log.AddContext(p.RequestID, "signed_url", si.SignedSourceURL)

if si.GenerateMP4 {
log.Log(si.RequestID, "MP4s will be generated", "duration", si.InputFileInfo.Duration)
}

Check warning on line 308 in pipeline/coordinator.go

View check run for this annotation

Codecov / codecov/patch

pipeline/coordinator.go#L307-L308

Added lines #L307 - L308 were not covered by tests

c.startUploadJob(si)
return nil, nil
})
}

func ShouldGenerateMP4(sourceURL, mp4TargetUrl *url.URL, fragMp4TargetUrl *url.URL, mp4OnlyShort bool, durationSecs float64) bool {
// Skip mp4 generation if we weren't able to determine the duration of the input file for any reason
if durationSecs == 0.0 {
return false
}
// We're currently memory-bound for generating MP4s above a certain file size
// This has been hitting us for long recordings, so do a crude "is it longer than 3 hours?" check and skip the MP4 if it is
const maxRecordingMP4Duration = 12 * time.Hour
Expand Down
6 changes: 6 additions & 0 deletions pipeline/coordinator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -853,4 +853,10 @@ func TestMP4Generation(t *testing.T) {
ShouldGenerateMP4(hlsSourceURL, nil, nil, false, 60*60*13),
"SHOULD NOT generate an MP4 if no valid mp4 or fmp4 URL was provided",
)

require.False(
t,
ShouldGenerateMP4(hlsSourceURL, mp4TargetURL, fragMp4TargetURL, false, 0),
"SHOULD NOT generate an MP4 if duration is 0 regardless of a valid mp4/fmp4 URL",
)
}

0 comments on commit a78b219

Please sign in to comment.