Skip to content

Commit

Permalink
muxer: put EXT-X-MEDIA before EXT-X-STREAM (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 authored Sep 22, 2024
1 parent ef68587 commit a6d4897
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
12 changes: 6 additions & 6 deletions pkg/playlist/multivariant.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,6 @@ func (m Multivariant) Marshal() ([]byte, error) {
ret += m.Start.marshal()
}

ret += "\n"

for _, v := range m.Variants {
ret += v.marshal()
}

if len(m.Renditions) != 0 {
ret += "\n"

Expand All @@ -135,5 +129,11 @@ func (m Multivariant) Marshal() ([]byte, error) {
}
}

ret += "\n"

for _, v := range m.Variants {
ret += v.marshal()
}

return []byte(ret), nil
}
30 changes: 15 additions & 15 deletions pkg/playlist/multivariant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,17 @@ var casesMultivariant = []struct {
"#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\"" +
",DEFAULT=YES,AUTOSELECT=YES,CHANNELS=\"2\",URI=\"audio.m3u8\"\n" +
"#EXT-X-MEDIA:TYPE=\"SUBTITLES\",GROUP-ID=\"sub1\",LANGUAGE=\"en\",NAME=\"english\"" +
",DEFAULT=YES,AUTOSELECT=YES,FORCED=NO,URI=\"sub.m3u8\"\n" +
"\n" +
"#EXT-X-STREAM-INF:BANDWIDTH=155000,AVERAGE-BANDWIDTH=120000,CODECS=\"avc1.42c028,mp4a.40.2\"" +
",RESOLUTION=1280x720,FRAME-RATE=24.000,AUDIO=\"aud1\",SUBTITLES=\"sub1\"\n" +
"stream1.m3u8\n" +
"#EXT-X-STREAM-INF:BANDWIDTH=55000,AVERAGE-BANDWIDTH=20000,CODECS=\"avc1.42c028,mp4a.40.2\"" +
",RESOLUTION=1280x720,FRAME-RATE=24.000\n" +
"stream2.m3u8\n" +
"\n" +
"#EXT-X-MEDIA:TYPE=\"AUDIO\",GROUP-ID=\"aud1\",LANGUAGE=\"en\",NAME=\"english\"" +
",DEFAULT=YES,AUTOSELECT=YES,CHANNELS=\"2\",URI=\"audio.m3u8\"\n" +
"#EXT-X-MEDIA:TYPE=\"SUBTITLES\",GROUP-ID=\"sub1\",LANGUAGE=\"en\",NAME=\"english\"" +
",DEFAULT=YES,AUTOSELECT=YES,FORCED=NO,URI=\"sub.m3u8\"\n",
"stream2.m3u8\n",
Multivariant{
Version: 9,
IndependentSegments: true,
Expand Down Expand Up @@ -204,6 +204,12 @@ v2/prog_index.m3u8
#EXT-X-VERSION:6
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MEDIA:TYPE="AUDIO",GROUP-ID="aud1",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,CHANNELS="2",URI="a1/prog_index.m3u8"
#EXT-X-MEDIA:TYPE="AUDIO",GROUP-ID="aud2",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,CHANNELS="6",URI="a2/prog_index.m3u8"
#EXT-X-MEDIA:TYPE="AUDIO",GROUP-ID="aud3",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,CHANNELS="6",URI="a3/prog_index.m3u8"
#EXT-X-MEDIA:TYPE="CLOSED-CAPTIONS",GROUP-ID="cc1",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES
#EXT-X-MEDIA:TYPE="SUBTITLES",GROUP-ID="sub1",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,FORCED=NO,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
#EXT-X-STREAM-INF:BANDWIDTH=8001098,AVERAGE-BANDWIDTH=7968416,CODECS="avc1.64002a,mp4a.40.2",RESOLUTION=1920x1080,FRAME-RATE=60.000,AUDIO="aud1",SUBTITLES="sub1",CLOSED-CAPTIONS="cc1"
Expand Down Expand Up @@ -252,12 +258,6 @@ v4/prog_index.m3u8
v3/prog_index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=571555,AVERAGE-BANDWIDTH=561224,CODECS="avc1.640015,ec-3",RESOLUTION=480x270,FRAME-RATE=30.000,AUDIO="aud3",SUBTITLES="sub1",CLOSED-CAPTIONS="cc1"
v2/prog_index.m3u8
#EXT-X-MEDIA:TYPE="AUDIO",GROUP-ID="aud1",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,CHANNELS="2",URI="a1/prog_index.m3u8"
#EXT-X-MEDIA:TYPE="AUDIO",GROUP-ID="aud2",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,CHANNELS="6",URI="a2/prog_index.m3u8"
#EXT-X-MEDIA:TYPE="AUDIO",GROUP-ID="aud3",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,CHANNELS="6",URI="a3/prog_index.m3u8"
#EXT-X-MEDIA:TYPE="CLOSED-CAPTIONS",GROUP-ID="cc1",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES
#EXT-X-MEDIA:TYPE="SUBTITLES",GROUP-ID="sub1",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,FORCED=NO,URI="s1/en/prog_index.m3u8"
`,
Multivariant{
Version: 6,
Expand Down Expand Up @@ -687,6 +687,9 @@ 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-STREAM-INF:BANDWIDTH=546902,CODECS="avc1.64000d,mp4a.40.2",RESOLUTION=320x180,AUDIO="audio"
QualityLevels(393546)/Manifest(video,format=m3u8-aapl)
#EXT-X-STREAM-INF:BANDWIDTH=801672,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,AUDIO="audio"
Expand All @@ -703,9 +706,6 @@ QualityLevels(3385171)/Manifest(video,format=m3u8-aapl)
QualityLevels(4681440)/Manifest(video,format=m3u8-aapl)
#EXT-X-STREAM-INF:BANDWIDTH=6254125,CODECS="avc1.640028,mp4a.40.2",RESOLUTION=1920x1080,AUDIO="audio"
QualityLevels(5977913)/Manifest(video,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)"
`,
Multivariant{
Version: 4,
Expand Down

0 comments on commit a6d4897

Please sign in to comment.