commit 30f6a788fb582ac91996927fb9533dd1ec0cb0c4
parent aeced255c350bab7d38431993ca2485d4cfa2370
Author: Oliver Lowe <o@olowe.co>
Date: Wed, 22 May 2024 14:47:47 +1000
m3u8: add specific test for floating point, integer combo parsing
Because we can have a combination of both, and it's an important thing
to get right in AV!
Diffstat:
3 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/m3u8/lex_test.go b/m3u8/lex_test.go
@@ -7,7 +7,7 @@ import (
)
func TestLex(t *testing.T) {
- files := []string{"testdata/master.m3u8", "testdata/master-with-alternatives.m3u8"}
+ files := []string{"testdata/master.m3u8"}
for _, name := range files {
fname := path.Base(name)
t.Run(fname, func(t *testing.T) {
diff --git a/m3u8/parse_test.go b/m3u8/parse_test.go
@@ -86,3 +86,22 @@ func TestParseClosedCaptions(t *testing.T) {
t.Errorf("want closed captions %s, got %s", want, cc2)
}
}
+
+// Tests that we parse floats and integers of different precisions ok.
+func TestFrameRate(t *testing.T) {
+ f, err := os.Open("testdata/frame_rate.m3u8")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer f.Close()
+ plist, err := ParsePlaylist(f)
+ if err != nil {
+ t.Fatal(err)
+ }
+ rates := []float32{24, 25, 29.97, 30, 23.976, 60}
+ for i, v := range plist.Variants {
+ if v.FrameRate != rates[i] {
+ t.Errorf("want %f, got %f", rates[i], v.FrameRate)
+ }
+ }
+}
diff --git a/m3u8/testdata/frame_rate.m3u8 b/m3u8/testdata/frame_rate.m3u8
@@ -0,0 +1,13 @@
+#EXTM3U
+#EXT-X-STREAM-INF:FRAME-RATE=24.000,
+film.m3u8
+#EXT-X-STREAM-INF:FRAME-RATE=25
+PAL.m3u8
+#EXT-X-STREAM-INF:FRAME-RATE=29.97
+NTSC-DROP.m3u8
+#EXT-X-STREAM-INF:FRAME-RATE=30.0
+NTSC.m3u8
+#EXT-X-STREAM-INF:FRAME-RATE=23.976
+NTSC-FILM.m3u8
+#EXT-X-STREAM-INF:FRAME-RATE=60.0000000
+YOUTUBE60fps.m3u8