M3U8Decoder icon indicating copy to clipboard operation
M3U8Decoder copied to clipboard

Performance Issue

Open anelad opened this issue 10 months ago • 4 comments

Hi. First of all, thanks for your contribution to the open source family 🫡

The package is very useful for small playlists but for large ones; I cannot say the same for the playlist I have.

It consists of 194.918 (EXTINF, URI) pairs and single EXTM3U entry with 22,1 MB in size.

Decoding it takes around 5.5 minutes with your package while VLC Player decodes in ~2 minutes. But the blowminding thing is a snippet from this medium post decodes the same playlist instantly (1.3 seconds). Of course the snippet does nothing but parsing it, no custom tags or any other features but instant vs 5.5 minutes is something very serious.

I think you should re-think about how you construct things.

Good luck ✌️

anelad avatar Apr 16 '24 18:04 anelad

Hi @anelad!

Thanks for your notice about the performance issues. Could you provide a link to your large m3u8 file to test and compare with other parsers?

ikhvorost avatar Apr 29 '24 09:04 ikhvorost

Here is the file I have

Of course I had to change the url, username and password so links are dead.

If you are on a Mac, OS won't open the file since it's origin is not known. You can "open anyway" from Settings -> Privacy & Security. I don't know about Windows or Linux distributions though.

Good luck!

anelad avatar May 07 '24 15:05 anelad

Hi @anelad!

There is new 2.0.0 version of the tool with parsing optimization. This version has predefined segments property to deal with Media Segments now, e.g.:

struct MediaPlaylist: Decodable {
  let segments: [MediaSegment]
}

let playlist = try M3U8Decoder().decode(MediaPlaylist.self, from: url)

I've got the following results:

  • Mac M1: ~3-5 secs
  • iPhone 11: ~5-6 mins

ikhvorost avatar Jul 23 '24 07:07 ikhvorost

Hello again @ikhvorost,

Thanks for the update. Currently I have some health issues but I'll give it a look as soon as possible.

Have a good day 👋

anelad avatar Jul 25 '24 18:07 anelad

Can I work on this issue? kindly assign it to me

mcrkgus avatar Dec 19 '24 07:12 mcrkgus