-
Notifications
You must be signed in to change notification settings - Fork 6
/
mp4_test.go
68 lines (54 loc) · 1.05 KB
/
mp4_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package mp4_test
import (
"os"
"testing"
"github.com/tajtiattila/metadata/mp4"
"github.com/tajtiattila/metadata/testutil"
)
func TestParse(t *testing.T) {
fileList := testutil.MediaFileInfos(t)
for _, e := range fileList {
testParse(t, e)
}
}
func testParse(t *testing.T, e testutil.FileInfo) {
if _, ok := e["Error"]; ok {
// exiftool found error parsing
return
}
fn, ok := e.String("SourceFile")
if !ok {
return
}
if tp, ok := e.String("FileType"); !ok || tp != "MP4" {
return
}
ex, ok := e.Int("ImageWidth")
if !ok {
return
}
ey, ok := e.Int("ImageHeight")
if !ok {
return
}
f, err := os.Open(fn)
if err != nil {
t.Errorf("Open %q error: %v", fn, err)
return
}
defer f.Close()
movie, err := mp4.Parse(f)
if err != nil {
t.Errorf("mp4.Parse of %q error: %v", fn, err)
return
}
sx, sy, err := movie.FrameSize()
if err != nil {
t.Errorf("movie FrameSize error: %v", err)
return
}
t.Logf("%q %vx%v\n", fn, sx, sy)
if ex != sx || ey != sy {
t.Errorf("got size %vx%v, want %vx%v", sx, sy, ex, ey)
}
}