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

transcode: add logic to force a session re-init #902

Merged
merged 3 commits into from
Oct 6, 2023

Conversation

emranemran
Copy link
Collaborator

When a sequence of segments has a discontinuity (e.g. encoded differently), the transcoder at T must be re-initialized so that transcode operations can be completed correctly. The T takes some liberties and assumes a sequence of segments are encoded the same way and thus, ends up not re-initializing certain parts of the pipeline (e.g. demuxer, etc) to save time and improve efficiency. This can result in corrupted segments with two video tracks instead of one audio and one video track.

For clipping, the first segment (index=0) is encoded differently from the rest of the file. As such, a session reinit must be forced at the T using a header set in the request to B.

When a sequence of segments has a discontinuity (e.g. encoded
differently), the transcoder at T must be re-initialized so that
transcode operations can be completed correctly. The T takes some
liberties and assumes a sequence of segments are encoded the same way
and thus, ends up not re-initializing certain parts of the pipeline
(e.g. demuxer, etc) to save time and improve efficiency. This can result
in corrupted segments with two video tracks instead of one audio and one
video track.

For clipping, the first segment (index=0) is encoded differently from
the rest of the file. As such, a session reinit must be forced at the T
using a header set in the request to B.
@emranemran emranemran force-pushed the emran/force-session-reinit-catalyst branch from 56d15cb to a76bd68 Compare October 6, 2023 03:18
@codecov
Copy link

codecov bot commented Oct 6, 2023

Codecov Report

Merging #902 (6fa1d42) into main (0a68878) will decrease coverage by 0.05186%.
Report is 9 commits behind head on main.
The diff coverage is 18.51852%.

Impacted file tree graph

@@                 Coverage Diff                 @@
##                main        #902         +/-   ##
===================================================
- Coverage   51.00439%   50.95253%   -0.05186%     
===================================================
  Files             63          63                 
  Lines           6372        6404         +32     
===================================================
+ Hits            3250        3263         +13     
- Misses          2858        2874         +16     
- Partials         264         267          +3     
Files Coverage Δ
clients/broadcaster.go 0.00000% <ø> (ø)
clients/broadcaster_local.go 0.00000% <0.00000%> (ø)
pipeline/ffmpeg.go 35.38462% <0.00000%> (-0.13662%) ⬇️
clients/manifest.go 43.11594% <0.00000%> (+0.15565%) ⬆️
transcode/transcode.go 37.30964% <70.00000%> (+1.57631%) ⬆️
pipeline/coordinator.go 77.67857% <0.00000%> (-1.23299%) ⬇️
video/clip.go 34.64052% <2.22222%> (-2.16504%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2eeb00c...6fa1d42. Read the comment docs.

Files Coverage Δ
clients/broadcaster.go 0.00000% <ø> (ø)
clients/broadcaster_local.go 0.00000% <0.00000%> (ø)
pipeline/ffmpeg.go 35.38462% <0.00000%> (-0.13662%) ⬇️
clients/manifest.go 43.11594% <0.00000%> (+0.15565%) ⬆️
transcode/transcode.go 37.30964% <70.00000%> (+1.57631%) ⬆️
pipeline/coordinator.go 77.67857% <0.00000%> (-1.23299%) ⬇️
video/clip.go 34.64052% <2.22222%> (-2.16504%) ⬇️

Copy link
Contributor

@leszko leszko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good. However, before the new go-livepeer version adoption we may need to have a hacky workaround and change manifestID for the clipped segments.

if transcodeRequest.IsClip && int64(segment.Index) == 1 {
transcodeConf.ForceSessionReinit = true
} else {
transcodeConf.ForceSessionReinit = false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I think you can skip this else since false is the default value of bool.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or just transcodeConf.ForceSessionReinit = transcodeRequest.IsClip && int64(segment.Index) == 1

Copy link
Contributor

@mjh1 mjh1 Oct 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not need a re-init for the final segment too (when that's also clipped)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not need a re-init for the final segment too (when that's also clipped)?

That's a good point. I guess that yes!

Copy link
Collaborator Author

@emranemran emranemran Oct 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not need a re-init for the final segment too (when that's also clipped)?

No actually, surprisingly. For some reason, the transcoder session is able to handle going from source recording segment to final segment that's also clipped (i.e re-encoded differently). Need to understand lpms better to understand why that is. Planning to follow up with clipping directly at T layer and hopefully understand this better.

@emranemran emranemran force-pushed the emran/force-session-reinit-catalyst branch from fa5afe8 to 0f6ece2 Compare October 6, 2023 11:54
@emranemran emranemran merged commit 49a28c3 into main Oct 6, 2023
12 checks passed
@emranemran emranemran deleted the emran/force-session-reinit-catalyst branch October 6, 2023 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants