m3u8-file-parser icon indicating copy to clipboard operation
m3u8-file-parser copied to clipboard

Incorrect resolution parsing

Open fan-tom opened this issue 6 years ago • 3 comments

Section 4.3.4.2 defines RESOLUTION attribute of EXT-X-STREAM-INF tag as decimal-resolution, that means it must not be parsed as integer. For example for the next playlist

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:BANDWIDTH=140800,RESOLUTION=480x360,CODECS="avc1.64001e,mp4a.40.2"
stream_0.m3u8

current implementation gives

'{
"isExtendedM3U":true,
"segments":
[
{
"isMasterPlaylist":true,
  "streamInf":{
    "bandwidth":140800,
    "resolution":480, // <- should be 480x360
    "codecs":["avc1.64001e,mp4a.40.2"]
  },
  "url":"stream_0.m3u8"
},
],
"version":3
}'

fan-tom avatar Oct 07 '19 06:10 fan-tom

First of all, thanks for your report and PR :) There are some problems I am having: when the input is "1080", it would simply output 1080, when the input is "2560x1440" it would output [2560, 1440]; should we consider parse the first one as [1080, undefined] ?

NimitzDEV avatar Oct 07 '19 15:10 NimitzDEV

I did it to be backward-compatible, but if it isn't the case, I can refactor to always return tuple of width and height

fan-tom avatar Oct 07 '19 16:10 fan-tom

I think I was wrong at the beginning to parse the value using parseInt, so I think it should be changed.

NimitzDEV avatar Oct 08 '19 06:10 NimitzDEV