-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinput_test.go
60 lines (47 loc) · 1.07 KB
/
input_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
package input
import (
_ "fmt"
_ "github.com/asticode/goav/avcodec"
_ "github.com/asticode/goav/avformat"
"testing"
)
const (
filename = "../assets/small.mp4"
)
func TestOpenClose(t *testing.T) {
context := NewContext()
if context.FormatCtx == nil {
t.Error("Format context not created")
}
t.Run("OpenFileAndCodecs", func(t *testing.T) {
err := context.OpenInput(filename)
if err != nil {
t.Error(err)
}
nrStreams := len(context.Streams)
if nrStreams != 2 {
t.Errorf("Missing streams, found %d\n", nrStreams)
}
})
t.Run("DecodeInput", func(t *testing.T) {
c := context.ReadInput()
frames := context.DecodeStream(c)
count := 0
for frame := range frames {
avFrame := frame.AVFrame
width := avFrame.Width()
height := avFrame.Height()
//fmt.Printf("Format: %d audio type: %v\n", format,
// avcodec.AVMEDIA_TYPE_AUDIO)
if width != 0 && height != 0 {
count++
}
}
if count != 166 {
t.Errorf("Incorrect number %d of frames decoded\n", count)
}
})
t.Run("CloseInput", func(t *testing.T) {
context.CloseInput()
})
}