Skip to content

Commit

Permalink
fix VLC compatibility (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 authored Dec 24, 2024
1 parent 294c8e1 commit b9f0e27
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
18 changes: 9 additions & 9 deletions muxer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ func TestMuxer(t *testing.T) {
"#EXT-X-VERSION:9\n"+
"#EXT-X-INDEPENDENT-SEGMENTS\n"+
"\n"+
"#EXT-X-MEDIA:TYPE=\"AUDIO\",GROUP-ID=\"audio\","+
"#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID=\"audio\","+
"NAME=\"audio2\",AUTOSELECT=YES,DEFAULT=YES,URI=\"audio2_stream.m3u8?key=value\"\n"+
"\n"+
"#EXT-X-STREAM-INF:BANDWIDTH=872,AVERAGE-BANDWIDTH=436,CODECS=\"avc1.42c028,mp4a.40.2\","+
Expand All @@ -407,7 +407,7 @@ func TestMuxer(t *testing.T) {
"#EXT-X-VERSION:9\n"+
"#EXT-X-INDEPENDENT-SEGMENTS\n"+
"\n"+
"#EXT-X-MEDIA:TYPE=\"AUDIO\",GROUP-ID=\"audio\","+
"#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID=\"audio\","+
"NAME=\"audio2\",AUTOSELECT=YES,DEFAULT=YES,URI=\"audio2_stream.m3u8?key=value\"\n"+
"\n"+
"#EXT-X-STREAM-INF:BANDWIDTH=872,AVERAGE-BANDWIDTH=584,CODECS=\"avc1.42c028,mp4a.40.2\","+
Expand Down Expand Up @@ -470,9 +470,9 @@ func TestMuxer(t *testing.T) {
"#EXT-X-VERSION:9\n"+
"#EXT-X-INDEPENDENT-SEGMENTS\n"+
"\n"+
"#EXT-X-MEDIA:TYPE=\"AUDIO\",GROUP-ID=\"audio\","+
"#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID=\"audio\","+
"NAME=\"audio2\",AUTOSELECT=YES,DEFAULT=YES,URI=\"audio2_stream.m3u8?key=value\"\n"+
"#EXT-X-MEDIA:TYPE=\"AUDIO\",GROUP-ID=\"audio\","+
"#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID=\"audio\","+
"LANGUAGE=\"de\",NAME=\"German\",AUTOSELECT=YES,URI=\"audio3_stream.m3u8?key=value\"\n"+
"\n"+
"#EXT-X-STREAM-INF:BANDWIDTH=872,AVERAGE-BANDWIDTH=403,"+
Expand All @@ -484,8 +484,8 @@ func TestMuxer(t *testing.T) {
"#EXT-X-VERSION:9\n"+
"#EXT-X-INDEPENDENT-SEGMENTS\n"+
"\n"+
"#EXT-X-MEDIA:TYPE=\"AUDIO\",GROUP-ID=\"audio\",NAME=\"audio1\",AUTOSELECT=YES,DEFAULT=YES\n"+
"#EXT-X-MEDIA:TYPE=\"AUDIO\",GROUP-ID=\"audio\",LANGUAGE=\"de\",NAME=\"German\","+
"#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID=\"audio\",NAME=\"audio1\",AUTOSELECT=YES,DEFAULT=YES\n"+
"#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID=\"audio\",LANGUAGE=\"de\",NAME=\"German\","+
"AUTOSELECT=YES,URI=\"audio2_stream.m3u8?key=value\"\n"+
"\n"+
"#EXT-X-STREAM-INF:BANDWIDTH=5184,AVERAGE-BANDWIDTH=3744,CODECS=\"mp4a.40.2\",AUDIO=\"audio\"\n"+
Expand All @@ -496,8 +496,8 @@ func TestMuxer(t *testing.T) {
"#EXT-X-VERSION:9\n"+
"#EXT-X-INDEPENDENT-SEGMENTS\n"+
"\n"+
"#EXT-X-MEDIA:TYPE=\"AUDIO\",GROUP-ID=\"audio\",NAME=\"audio1\",AUTOSELECT=YES,DEFAULT=YES\n"+
"#EXT-X-MEDIA:TYPE=\"AUDIO\",GROUP-ID=\"audio\",LANGUAGE=\"de\",NAME=\"German\","+
"#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID=\"audio\",NAME=\"audio1\",AUTOSELECT=YES,DEFAULT=YES\n"+
"#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID=\"audio\",LANGUAGE=\"de\",NAME=\"German\","+
"AUTOSELECT=YES,URI=\"audio2_stream.m3u8?key=value\"\n"+
"\n"+
"#EXT-X-STREAM-INF:BANDWIDTH=5568,AVERAGE-BANDWIDTH=4000,CODECS=\"mp4a.40.2\",AUDIO=\"audio\"\n"+
Expand Down Expand Up @@ -1221,7 +1221,7 @@ func TestMuxerFMP4NegativeTimestamp(t *testing.T) {
"#EXT-X-VERSION:9\n"+
"#EXT-X-INDEPENDENT-SEGMENTS\n"+
"\n"+
`#EXT-X-MEDIA:TYPE="AUDIO",GROUP-ID="audio",NAME="audio2",AUTOSELECT=YES,DEFAULT=YES,URI="audio2_stream.m3u8"`+"\n"+
`#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",NAME="audio2",AUTOSELECT=YES,DEFAULT=YES,URI="audio2_stream.m3u8"`+"\n"+
"\n"+
`#EXT-X-STREAM-INF:BANDWIDTH=644,AVERAGE-BANDWIDTH=550,`+
`CODECS="avc1.42c028,mp4a.40.2",RESOLUTION=1920x1080,FRAME-RATE=30.000,AUDIO="audio"`+"\n"+
Expand Down
2 changes: 1 addition & 1 deletion pkg/playlist/multivariant_rendition.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (t *MultivariantRendition) unmarshal(v string) error {
}

func (t MultivariantRendition) marshal() string {
ret := "#EXT-X-MEDIA:TYPE=\"" + string(t.Type) + "\",GROUP-ID=\"" + t.GroupID + "\""
ret := "#EXT-X-MEDIA:TYPE=" + string(t.Type) + ",GROUP-ID=\"" + t.GroupID + "\""

if t.Language != "" {
ret += ",LANGUAGE=\"" + t.Language + "\""
Expand Down
24 changes: 12 additions & 12 deletions pkg/playlist/multivariant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,18 @@ var casesMultivariant = []struct {
",RESOLUTION=1280x720,FRAME-RATE=24.000\n" +
"stream2.m3u8\n" +
"\n" +
"#EXT-X-MEDIA:TYPE=\"AUDIO\",GROUP-ID=\"aud1\",LANGUAGE=\"en\",NAME=\"english\"" +
"#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID=\"aud1\",LANGUAGE=\"en\",NAME=\"english\"" +
",AUTOSELECT=YES,DEFAULT=YES,CHANNELS=\"2\",URI=\"audio.m3u8\"\n" +
"#EXT-X-MEDIA:TYPE=\"SUBTITLES\",GROUP-ID=\"sub1\",LANGUAGE=\"en\",NAME=\"english\"" +
"#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID=\"sub1\",LANGUAGE=\"en\",NAME=\"english\"" +
",AUTOSELECT=YES,DEFAULT=YES,FORCED=NO,URI=\"sub.m3u8\"\n",
"#EXTM3U\n" +
"#EXT-X-VERSION:9\n" +
"#EXT-X-INDEPENDENT-SEGMENTS\n" +
"#EXT-X-START:TIME-OFFSET=15.00000\n" +
"\n" +
"#EXT-X-MEDIA:TYPE=\"AUDIO\",GROUP-ID=\"aud1\",LANGUAGE=\"en\",NAME=\"english\"" +
"#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID=\"aud1\",LANGUAGE=\"en\",NAME=\"english\"" +
",AUTOSELECT=YES,DEFAULT=YES,CHANNELS=\"2\",URI=\"audio.m3u8\"\n" +
"#EXT-X-MEDIA:TYPE=\"SUBTITLES\",GROUP-ID=\"sub1\",LANGUAGE=\"en\",NAME=\"english\"" +
"#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID=\"sub1\",LANGUAGE=\"en\",NAME=\"english\"" +
",AUTOSELECT=YES,DEFAULT=YES,URI=\"sub.m3u8\"\n" +
"\n" +
"#EXT-X-STREAM-INF:BANDWIDTH=155000,AVERAGE-BANDWIDTH=120000,CODECS=\"avc1.42c028,mp4a.40.2\"" +
Expand Down Expand Up @@ -208,11 +208,11 @@ v2/prog_index.m3u8
#EXT-X-VERSION:6
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MEDIA:TYPE="AUDIO",GROUP-ID="aud1",LANGUAGE="en",NAME="English",AUTOSELECT=YES,DEFAULT=YES,CHANNELS="2",URI="a1/prog_index.m3u8"
#EXT-X-MEDIA:TYPE="AUDIO",GROUP-ID="aud2",LANGUAGE="en",NAME="English",AUTOSELECT=YES,DEFAULT=YES,CHANNELS="6",URI="a2/prog_index.m3u8"
#EXT-X-MEDIA:TYPE="AUDIO",GROUP-ID="aud3",LANGUAGE="en",NAME="English",AUTOSELECT=YES,DEFAULT=YES,CHANNELS="6",URI="a3/prog_index.m3u8"
#EXT-X-MEDIA:TYPE="CLOSED-CAPTIONS",GROUP-ID="cc1",LANGUAGE="en",NAME="English",AUTOSELECT=YES,DEFAULT=YES,INSTREAM-ID="CC1"
#EXT-X-MEDIA:TYPE="SUBTITLES",GROUP-ID="sub1",LANGUAGE="en",NAME="English",AUTOSELECT=YES,DEFAULT=YES,URI="s1/en/prog_index.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aud1",LANGUAGE="en",NAME="English",AUTOSELECT=YES,DEFAULT=YES,CHANNELS="2",URI="a1/prog_index.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aud2",LANGUAGE="en",NAME="English",AUTOSELECT=YES,DEFAULT=YES,CHANNELS="6",URI="a2/prog_index.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aud3",LANGUAGE="en",NAME="English",AUTOSELECT=YES,DEFAULT=YES,CHANNELS="6",URI="a3/prog_index.m3u8"
#EXT-X-MEDIA:TYPE=CLOSED-CAPTIONS,GROUP-ID="cc1",LANGUAGE="en",NAME="English",AUTOSELECT=YES,DEFAULT=YES,INSTREAM-ID="CC1"
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="sub1",LANGUAGE="en",NAME="English",AUTOSELECT=YES,DEFAULT=YES,URI="s1/en/prog_index.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=2177116,AVERAGE-BANDWIDTH=2168183,CODECS="avc1.640020,mp4a.40.2",RESOLUTION=960x540,FRAME-RATE=60.000,AUDIO="aud1",SUBTITLES="sub1",CLOSED-CAPTIONS="cc1"
v5/prog_index.m3u8
Expand Down Expand Up @@ -691,8 +691,8 @@ QualityLevels(5977913)/Manifest(video,format=m3u8-aapl)
`#EXTM3U
#EXT-X-VERSION:4
#EXT-X-MEDIA:TYPE="AUDIO",GROUP-ID="audio",NAME="AAC_und_ch2_128kbps",URI="QualityLevels(125615)/Manifest(AAC_und_ch2_128kbps,format=m3u8-aapl)"
#EXT-X-MEDIA:TYPE="AUDIO",GROUP-ID="audio",NAME="AAC_und_ch2_56kbps",DEFAULT=YES,URI="QualityLevels(53620)/Manifest(AAC_und_ch2_56kbps,format=m3u8-aapl)"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",NAME="AAC_und_ch2_128kbps",URI="QualityLevels(125615)/Manifest(AAC_und_ch2_128kbps,format=m3u8-aapl)"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",NAME="AAC_und_ch2_56kbps",DEFAULT=YES,URI="QualityLevels(53620)/Manifest(AAC_und_ch2_56kbps,format=m3u8-aapl)"
#EXT-X-STREAM-INF:BANDWIDTH=546902,CODECS="avc1.64000d,mp4a.40.2",RESOLUTION=320x180,AUDIO="audio"
QualityLevels(393546)/Manifest(video,format=m3u8-aapl)
Expand Down Expand Up @@ -868,7 +868,7 @@ func TestMultivariantMarshal(t *testing.T) {
t.Run(ca.name, func(t *testing.T) {
byts, err := ca.dec.Marshal()
require.NoError(t, err)
require.Equal(t, string(byts), ca.output)
require.Equal(t, ca.output, string(byts))
})
}
}
Expand Down

0 comments on commit b9f0e27

Please sign in to comment.