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

MP4 regex doesn't work for URLs with query string #3756

Closed
GitBoudewijn opened this issue Apr 10, 2021 · 5 comments · Fixed by #3758
Closed

MP4 regex doesn't work for URLs with query string #3756

GitBoudewijn opened this issue Apr 10, 2021 · 5 comments · Fixed by #3758

Comments

@GitBoudewijn
Copy link

See the regex to detect MP4 fragments here:
https://github.com/video-dev/hls.js/blob/master/src/loader/m3u8-parser.ts#L62
const MP4_REGEX_SUFFIX = /\.(mp4|m4s|m4v|m4a)$/i;

This regex doesn't work if the file URL has a query string like xxx.m4s?y=1.

@tjenkinson
Copy link
Member

@GitBoudewijn please can you try now on https://deploy-preview-3758--hls-js-dev.netlify.app/ (#3758)?

@tjenkinson tjenkinson added the Bug label Apr 10, 2021
@robwalch
Copy link
Collaborator

robwalch commented Apr 10, 2021

Hi @GitBoudewijn,

Can you provide a sample stream with SIDX that requires this fix?

It's important for us to have a sample steam for these reasons

  • The project is missing SIDX test media that test the code in question
    • also some missing expertise on my part: why would you have a stream like this, how can I make one?
  • Inferring info from file extensions is not bulletproof / having a test stream would allow us to explore alternative solutions
  • Is this configuration spec-compliant and/or is it supported by Safari <video src=?

@robwalch robwalch added this to the 1.0.1 milestone Apr 10, 2021
@robwalch robwalch added this to Top priorities in Release Planning and Backlog via automation Apr 10, 2021
@GitBoudewijn
Copy link
Author

GitBoudewijn commented Apr 11, 2021

Sorry I don't actually have a real stream like this. I just noticed this while looking at the source code because I'm trying to understand how SIDX works myself.

I did find this dash playlist which contains mp4 files with SIDX:
http://dash.edgesuite.net/akamai/streamroot/050714/Spring_4Ktest.mpd

But when I try this:

#EXTM3U
#EXT-X-VERSION:7
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-TARGETDURATION:20
#EXTINF:20,
http://dash.edgesuite.net/akamai/streamroot/050714/Spring_20000k_track1_dashinit.mp4
#EXT-X-ENDLIST

This happens:

Uncaught TypeError: Cannot read property 'byteRange' of undefined
    at hls.js@latest:1
    at Array.forEach (<anonymous>)
    at t.e.handleSidxRequest (hls.js@latest:1)
    at t.e.loadsuccess (hls.js@latest:1)
    at t.e.readystatechange (hls.js@latest:1)

Edit: I looked at the source code again and I understand how it works now. When there's no #EXT-X-MAP it fetches the SIDX and then updates the #EXT-X-BYTERANGE for every existing fragment in the playlist, so it will give this error if the number of fragments in the playlist is less than the number in the SIDX.

So maybe you could first check if the number of fragments is equal to the number in the SIDX (reference_count). If it's not and the urls of all the fragments in the playlist are the same you could just disregard them entirely and generate new fragments based on the SIDX. (If you want to cover all cases.)

@robwalch
Copy link
Collaborator

robwalch commented Apr 12, 2021

I merged the regex patch, but to dig deeper we'll need a new issue outlining the requirements or bug with a valid sample stream. The dash.edgesuite to HLS example above does not look to be valid.

@ghost
Copy link

ghost commented Jan 25, 2023

<title>Teste de Canal</title> $doregex[gloriosotv]|User-Agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 gloriosotv (https?://[^\s]+\.mp4) https://github.com/sandrojr1991/NOVELAS/releases/download/oclone/O.Clone.Capitulo.1.-.BY.SANDRO.STORE.mp4 https://i.imgur.com/MA24TG2.png Novelas me ajudem fazer esse regex funciona no kodi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Release Planning and Backlog
  
Top priorities
Development

Successfully merging a pull request may close this issue.

3 participants