Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip transcoding when empty profiles were sent to B #2883

Merged
merged 4 commits into from Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions server/broadcast.go
Expand Up @@ -939,6 +939,9 @@ func processSegment(ctx context.Context, cxn *rtmpConnection, seg *stream.HLSSeg
attempts []data.TranscodeAttemptInfo
urls []string
)
if len(cxn.params.Profiles) == 0 {
return []string{}, nil
}
for len(attempts) < MaxAttempts {
// if transcodeSegment fails, retry; rudimentary
var info *data.TranscodeAttemptInfo
Expand Down Expand Up @@ -970,6 +973,7 @@ func processSegment(ctx context.Context, cxn *rtmpConnection, seg *stream.HLSSeg
}
// recoverable error, retry
}

if MetadataQueue != nil {
success := err == nil && len(urls) > 0
streamID := string(mid)
Expand Down Expand Up @@ -1036,6 +1040,10 @@ func transcodeSegment(ctx context.Context, cxn *rtmpConnection, seg *stream.HLSS
if len(sessions) == 1 {
// shortcut for most common path
sess := sessions[0]
if len(sess.Params.Profiles) == 0 {
// If not profiles were requested, then skip transcoding
return []string{}, info, nil
}
if seg, err = prepareForTranscoding(ctx, cxn, sess, seg, name); err != nil {
return nil, info, err
}
Expand Down
4 changes: 1 addition & 3 deletions server/mediaserver.go
Expand Up @@ -302,7 +302,7 @@ func createRTMPStreamIDHandler(_ctx context.Context, s *LivepeerServer, webhookR
profiles = append(profiles, parsedProfiles...)

// Only set defaults if user did not specify a preset/profile
if len(resp.Profiles) <= 0 && len(resp.Presets) <= 0 {
if resp.Profiles == nil && len(resp.Presets) <= 0 {
profiles = BroadcastJobVideoProfiles
}

Expand Down Expand Up @@ -1032,8 +1032,6 @@ func (s *LivepeerServer) HandlePush(w http.ResponseWriter, r *http.Request) {
default:
}
if len(urls) == 0 {
clog.Errorf(ctx, "No sessions available name=%s url=%s", fname, r.URL)
http.Error(w, "No sessions available", http.StatusServiceUnavailable)
return
}
renditionData := make([][]byte, len(urls))
Expand Down