-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathmp4.go
40 lines (34 loc) · 771 Bytes
/
mp4.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
package mp4
import (
"bytes"
"io"
"os"
"github.com/alfg/mp4/atom"
)
// Open opens a file and returns an &Mp4Reader{}.
func Open(path string) (f *atom.Mp4Reader, err error) {
file, err := os.Open(path)
if err != nil {
return nil, err
}
f = &atom.Mp4Reader{
Reader: file,
}
return f, f.Parse()
}
// OpenFromReader read and returns an &Mp4Reader{}.
func OpenFromReader(reader io.ReaderAt, size int64) (f *atom.Mp4Reader, err error) {
f = &atom.Mp4Reader{
Reader: reader,
Size: int64(size),
}
return f, f.Parse()
}
// OpenFromBytes read and returns an &Mp4Reader{}.
func OpenFromBytes(buffer []byte) (f *atom.Mp4Reader, err error) {
f = &atom.Mp4Reader{
Reader: bytes.NewReader(buffer),
Size: int64(len(buffer)),
}
return f, f.Parse()
}