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

dateRanges[index].startDate undefined #186

Open
pmendozav opened this issue Nov 19, 2024 · 2 comments
Open

dateRanges[index].startDate undefined #186

pmendozav opened this issue Nov 19, 2024 · 2 comments

Comments

@pmendozav
Copy link

Error:

Image

Steps to replicate:

Unfortnately I cannot share the stream url but basically I was waiting for a long time and suddenly a playlist manifest started to include a tag EXT-X-DATERANGE with a field END-DATE but not START-DATE that m3u8-parser expects.

Basically I put a break point and wait:
Image

here is the value for this:
Image

Analysis

1. Observing this.lineStream.buffer:

#EXT-X-DATERANGE:ID="splice-0x9C6",END-DATE="2024-11-19T12:30:10.334833Z",DURATION=130.0,SCTE35-IN=0xFC302000000000000000FFF00F05000009C67F4FFF5A2E02770014000000008FBAEEA5
#EXTINF:6.16,
https://...52014694.ts
#EXTINF:6.0,
https://...52014695.ts

There is END-DATE but not START-DATE

2. To confirm, I checked t = this.manifest.dateRanges[e] with (e=1)

{
    "scte35In": "0xFC302000000000000000FFF00F05000009C67F4FFF5A2E02770014000000008FBAEEA5",
    "duration": 130,
    "endDate": "2024-11-19T12:30:10.334Z",
    "id": "splice-0x9C6"
}

3. My question:

In parser.js I see:

const dateRange = this.manifest.dateRanges[index]
// ...
if (dateRange.duration && dateRange.endDate) {
  const startDate = dateRange.startDate;
  const newDateInSeconds = startDate.getTime() + (dateRange.duration * 1000);

  this.manifest.dateRanges[index].endDate = new Date(newDateInSeconds);
}

So, are you checking if dateRange.endDate is defined to decide whether to update it? I'm unclear about that part. Shouldn't the criteria be dateRange.duration && dateRange.startDate? If dateRange.endDate is defined but one of the others is missing, we could just maintain the current daterange.endDate, right?

@adrums86
Copy link
Contributor

I think the issue here is more so that the stream is providing invalid EXT-X-DATERANGE tags: Per the spec:

START-DATE

      A quoted-string containing the [[ISO_8601](https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis-16#ref-ISO_8601)] date/time at which the
      Date Range begins.  This attribute is REQUIRED.

Although the parser doesn't explicitly check in this case, I think the motivation behind the endDate check comes from this bit in the EXT-X-DATERANGE portion of the spec:

If a Date Range contains both a DURATION attribute and an END-DATE
   attribute, the value of the END-DATE attribute MUST be equal to the
   value of the START-DATE attribute plus the value of the DURATION
   attribute.

   Clients SHOULD ignore EXT-X-DATERANGE tags with illegal syntax.

All that said, I agree we should be avoiding this error by checking for startDate and never entering this block to begin with. I think we may want to check for startDate && endDate and do a quick equality check if we really want this to be spec compliant.

@pmendozav
Copy link
Author

@adrums86 I added a warn event trigger if END-DATE and DURATION are present but START-DATE is missing. I also returned the END-DATE to the constraint to better align with the spec

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

No branches or pull requests

2 participants