-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
id3: add duration to metadata samples, mimic Safari behavior on unbounded cues #4967
Conversation
Hi @jprjr, To resolve this build error https://github.com/video-dev/hls.js/actions/runs/3251442546/jobs/5393313941#step:7:29\ The rest looks great! Infinite duration when possible and updating unbounded cues at once is a nice optimization and appears to match Safari well. |
Can do!
…On October 18, 2022 5:38:01 PM EDT, Rob Walch ***@***.***> wrote:
Hi @jprjr,
To resolve this build error https://github.com/video-dev/hls.js/actions/runs/3251442546/jobs/5393313941#step:7:29\
please run `npm run prettier` and commit the formatting changes.
--
Reply to this email directly or view it on GitHub:
#4967 (comment)
You are receiving this because you were mentioned.
Message ID: ***@***.***>
|
@robwalch I just pushed up another, more comprehensive attempt on this - it adds a duration field to Metadata samples and uses |
const Cue = getCueClass(); | ||
let updateCueRanges = false; | ||
const frameTypesAdded: Record<string, number | null> = {}; | ||
let updateCueRanges = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(@jprjr you can ignore the disclaimer above)
I see a discrepancy between the native and HLS.js behavior when a segment has two samples/frames starting at different times. Given these samples and parsed frames:
samples = [{
data: Uint8Array(71),
dts: 0.04401111111111078,
duration: Infinity,
len: 71,
pts: 0.04401111111111078,
type: "https://aomedia.org/emsg/ID3"
}, {
data: Uint8Array(71),
dts: 5.0440000000000005,
duration: Infinity,
len: 71,
pts: 5.0440000000000005,
type: "https://aomedia.org/emsg/ID3"
}];
frames = { // same for each sample
data: " *** THIS IS Timed MetaData *** "
info: ""
key: "TXXX"
}.
Safari native HLS playback lays them out one after the other:
With this changes in this PR, we get samples containing the same frame within a segment overlapping each other:
The current release produces the same results as Safari for cases like this, but the optimization to only update cues for each segment once seems to be introducing this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, yeah - I think I can change it to just always update any previously unbounded cues, I'll get an update pushed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@robwalch - made a change to update any previously-created, unbounded cues on any new ID3 frame, tested on Safari and it should match the behavior - let me know if these two commits should be squashed or kept as separate commits
unbounded cues. Related to video-dev#4964 On Safari, when an ID3 track is present, cues are initially created with an Infinite endTime for MPEG-TS and Packed Audio sources. With fragmented MP4, they may have an Infinite endTime if the duration is 0xffffffff, or very small - otherwise it's finite. As new ID3 tags come in, any unbounded cues have the endTime updated. The current draft of VTTCue allows an unrestricted double for the endTime - which allows for using Number.POSITIVE_INFINITY. It hasn't rolled out yet, so this falls back to Number.MAX_VALUE.
…nded cues (#4967) * id3: add duration to metadata samples, mimic Safari behavior on unbounded cues. Related to #4964 On Safari, when an ID3 track is present, cues are initially created with an Infinite endTime for MPEG-TS and Packed Audio sources. With fragmented MP4, they may have an Infinite endTime if the duration is 0xffffffff, or very small - otherwise it's finite. As new ID3 tags come in, any unbounded cues have the endTime updated. The current draft of VTTCue allows an unrestricted double for the endTime - which allows for using Number.POSITIVE_INFINITY. It hasn't rolled out yet, so this falls back to Number.MAX_VALUE. * id3: remove the optimization to only update cues once
This PR will...
event_duration
of 0xffffffff or <= .001 seconds.Number.MAX_VALUE
as a fallback.Why is this Pull Request needed?
On Safari, when an ID3 track is present, unbounded cues are initially created with an Infinite endTime. As new ID3 tags come in, all previous cues have the endTime updated. Cues may also have a valid endTime, if the underlying source supports it (fragmented mp4).
The current implementation is tracking for changes on the individual ID3 frame level, but Safari will update all existing, unbounded Cues, not just cues with the same ID3 frame ID.
Additionally, current implementation uses the playlist length - on a live playlist this is often quite short, and the Cue expires earlier than intended, especially if ID3 tags aren't being inserted often.
I have a short demo here comparing native, latest release, and this branch: https://jrjrtech.com/mpegts-loop/
Are there any points in the code the reviewer needs to double check?
The section that checks for a negative duration and sets a minimum duration. Infinity - (anything) is still infinity, so in the future I don't think it will be possible for that case to occur.
Resolves issues:
#4964 (fully)
Checklist