-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathshow.go
46 lines (36 loc) · 1.07 KB
/
show.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
package main
import (
"fmt"
"github.com/snoby/go-ffprobe"
)
var (
err error
fileFormat *ffprobe.Format
fileStreams []*ffprobe.Stream
)
func showFFprobeInfo(in string) {
h := ffprobe.File(in)
fileFormat, err = h.Format()
if err != nil {
fmt.Println("This file format doesn't seem to be known, exiting")
fmt.Println(err)
return
}
fileStreams, err = h.Streams()
if err != nil {
fmt.Println(err)
return
}
fmt.Printf(" Information about file: %s \n", fileFormat.Filename)
fmt.Printf(" Number of Streams: %d \n", fileFormat.NBStreams)
fmt.Printf(" File has duration: %s (s)\n", fileFormat.Duration)
for _, stream := range fileStreams {
if stream.CodecType == "audio" {
fmt.Printf("AudioStream: codec: %s channels: %+v bitrate: %s\n", stream.CodecName, stream.Channels, stream.BitRate)
} else if stream.CodecType == "video" {
fmt.Printf("VideoStream: codec: %s Profile: %s bitrate: %s \n", stream.CodecName, stream.Profile, stream.BitRate)
} else {
fmt.Printf("Data Stream: %s type: %s \n", stream.CodecName, stream.CodecType)
}
}
}