rutgersc / m3u8-rs

m3u8 parser for rust
MIT License
99 stars 27 forks source link

CLOSED-CAPTIONS=NONE case is not handled correctly #44

Closed vagetman closed 2 years ago

vagetman commented 2 years ago

Here is the original manifest for posterity.

#EXTM3U
#EXT-X-VERSION:6
## Created with Unified Streaming Platform (version=1.11.12-25516)

# AUDIO groups
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio-aacl-64",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,CHANNELS="2",URI="1645124292737-output_hls_dref-audio_eng=64000.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio-aacl-96",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,CHANNELS="2",URI="1645124292737-output_hls_dref-audio_eng=96000.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio-aacl-128",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,CHANNELS="2",URI="1645124292737-output_hls_dref-audio_eng=128000.m3u8"

# SUBTITLES groups
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="textstream",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,URI="1645124292737-output_hls_dref-textstream_eng=1000.m3u8"

# variants
#EXT-X-STREAM-INF:BANDWIDTH=228000,CODECS="mp4a.40.2,avc1.64000D",RESOLUTION=320x240,FRAME-RATE=29.97,VIDEO-RANGE=SDR,AUDIO="audio-aacl-64",SUBTITLES="textstream",CLOSED-CAPTIONS=NONE
1645124292737-output_hls_dref-video=150000.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=312000,CODECS="mp4a.40.2,avc1.64000D",RESOLUTION=416x312,FRAME-RATE=29.97,VIDEO-RANGE=SDR,AUDIO="audio-aacl-96",SUBTITLES="textstream",CLOSED-CAPTIONS=NONE
1645124292737-output_hls_dref-video=197000.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=467000,CODECS="mp4a.40.2,avc1.640015",RESOLUTION=480x360,FRAME-RATE=29.97,VIDEO-RANGE=SDR,AUDIO="audio-aacl-128",SUBTITLES="textstream",CLOSED-CAPTIONS=NONE
1645124292737-output_hls_dref-video=311000.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=746000,CODECS="mp4a.40.2,avc1.64001E",RESOLUTION=640x480,FRAME-RATE=29.97,VIDEO-RANGE=SDR,AUDIO="audio-aacl-128",SUBTITLES="textstream",CLOSED-CAPTIONS=NONE
1645124292737-output_hls_dref-video=574000.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=946000,CODECS="mp4a.40.2,avc1.64001E",RESOLUTION=768x576,FRAME-RATE=29.97,VIDEO-RANGE=SDR,AUDIO="audio-aacl-128",SUBTITLES="textstream",CLOSED-CAPTIONS=NONE
1645124292737-output_hls_dref-video=763000.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1127000,CODECS="mp4a.40.2,avc1.64001E",RESOLUTION=768x576,FRAME-RATE=29.97,VIDEO-RANGE=SDR,AUDIO="audio-aacl-128",SUBTITLES="textstream",CLOSED-CAPTIONS=NONE
1645124292737-output_hls_dref-video=934000.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2055000,CODECS="mp4a.40.2,avc1.64001F",RESOLUTION=1280x960,FRAME-RATE=29.97,VIDEO-RANGE=SDR,AUDIO="audio-aacl-128",SUBTITLES="textstream",CLOSED-CAPTIONS=NONE
1645124292737-output_hls_dref-video=1809000.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2489000,CODECS="mp4a.40.2,avc1.64001F",RESOLUTION=1280x960,FRAME-RATE=29.97,VIDEO-RANGE=SDR,AUDIO="audio-aacl-128",SUBTITLES="textstream",CLOSED-CAPTIONS=NONE
1645124292737-output_hls_dref-video=2219000.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=4315000,CODECS="mp4a.40.2,avc1.640028",RESOLUTION=1920x1440,FRAME-RATE=29.97,VIDEO-RANGE=SDR,AUDIO="audio-aacl-128",SUBTITLES="textstream",CLOSED-CAPTIONS=NONE
1645124292737-output_hls_dref-video=3941000.m3u8

# keyframes
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=20000,CODECS="avc1.64000D",RESOLUTION=320x240,VIDEO-RANGE=SDR,URI="keyframes/1645124292737-output_hls_dref-video=150000.m3u8"
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=27000,CODECS="avc1.64000D",RESOLUTION=416x312,VIDEO-RANGE=SDR,URI="keyframes/1645124292737-output_hls_dref-video=197000.m3u8"
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=42000,CODECS="avc1.640015",RESOLUTION=480x360,VIDEO-RANGE=SDR,URI="keyframes/1645124292737-output_hls_dref-video=311000.m3u8"
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=77000,CODECS="avc1.64001E",RESOLUTION=640x480,VIDEO-RANGE=SDR,URI="keyframes/1645124292737-output_hls_dref-video=574000.m3u8"
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=102000,CODECS="avc1.64001E",RESOLUTION=768x576,VIDEO-RANGE=SDR,URI="keyframes/1645124292737-output_hls_dref-video=763000.m3u8"
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=240000,CODECS="avc1.64001F",RESOLUTION=1280x960,VIDEO-RANGE=SDR,URI="keyframes/1645124292737-output_hls_dref-video=1809000.m3u8"
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=523000,CODECS="avc1.640028",RESOLUTION=1920x1440,VIDEO-RANGE=SDR,URI="keyframes/1645124292737-output_hls_dref-video=3941000.m3u8"

The problem here is that a in variant attribute CLOSED-CAPTIONS=NONE, the NONE is ingested as is and when rendered out by write_to() as double quoted, so it becomes a name for a GROUP-ID="NONE", which obviously is not present. Here is how the standard reads about this:

CLOSED-CAPTIONS

      The value can be either a quoted-string or an enumerated-string
      with the value NONE.  If the value is a quoted-string, it MUST
      match the value of the GROUP-ID attribute of an EXT-X-MEDIA tag
      elsewhere in the Playlist whose TYPE attribute is CLOSED-CAPTIONS,
      and it indicates the set of closed-caption Renditions that can be
      used when playing the presentation.  See [Section 4.4.6.2.1]

      If the value is the enumerated-string value NONE, all EXT-X-
      STREAM-INF tags MUST have this attribute with a value of NONE,
      indicating that there are no closed captions in any Variant Stream
      in the Multivariant Playlist.  Having closed captions in one
      Variant Stream but not another can trigger playback
      inconsistencies.

https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis-10#section-4.4.6.2

I will attach a PR with a proposed fix

sdroege commented 2 years ago

This is done now

vagetman commented 2 years ago

Thank you for merging this. I just noticed it's however not pushed to crates.io, cc @rutgersc

sdroege commented 2 years ago

Don't forget that it needs a new major version

vagetman commented 2 years ago

Don't forget that it needs a new major version

Oh, that why, right. I did forget, thanks...