-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
44 lines (34 loc) · 766 Bytes
/
main.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
package main
import (
"fmt"
_ "github.com/giorgisio/goav/avutil"
"gocoder/encode"
"gocoder/input"
"log"
)
func main() {
context := input.NewContext()
filename := "assets/small.mp4"
err := context.OpenInput(filename)
defer context.CloseInput()
if err != nil {
log.Printf("Could not open file: %v\n", err)
return
}
context.FindStreamInfo()
context.DumpStreamInfo()
for i, ctx := range context.Streams {
fmt.Printf("Stream %d stream %p\n", i, ctx)
}
// Demux
c := context.ReadInput()
// Decode
decodedFrames := context.DecodeStream(c)
// Encode
video := encode.NewVideoEncoder()
video.SetOptions(560, 320)
encodedFrames := video.Encode(decodedFrames)
for elem := range encodedFrames {
fmt.Printf("size: %d\n", elem.Size())
}
}