-
Notifications
You must be signed in to change notification settings - Fork 0
/
mpeg-dump.go
57 lines (50 loc) · 1.46 KB
/
mpeg-dump.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
// Copyright © 2014 Lawrence E. Bakst. All rights reserved.
package main
import "fmt"
import "flag"
//import "os"
//import "io"
import "leb.io/mpeg-decoder/bitstream"
import "leb.io/mpeg-decoder/iso11172"
var phdf = flag.Bool("phd", false, "print headers")
var pvsf = flag.Bool("pvs", false, "print video slices")
var pmbf = flag.Bool("pmb", false, "print macro blocks")
var pbcf = flag.Bool("pbc", false, "print block coefficients")
var prmbf = flag.Bool("prmb", false, "print raw macro blocks")
var rmbf = flag.Bool("rmb", true, "read macro blocks")
var vf = flag.Bool("v", false, "verbose; turns on all printing")
var psf = flag.Bool("ps", false, "print stats")
var from = flag.Int("from", 0, "start at frame #")
var to = flag.Int("to", 9999999, "stop at frame #")
func chk(i iso11172.Mpeg1Parser) {
_, ok := i.(iso11172.Mpeg1Parser)
//fmt.Printf("%T | %T\n", i, x)
if ok {
//fmt.Printf("OK")
} else {
fmt.Printf("BAD")
}
}
func main() {
flag.Parse()
if *vf {
*phdf, *pvsf, *pmbf = true, true, true
}
ms := iso11172.New(*phdf, *pvsf, *pmbf, *pbcf, *prmbf, *rmbf)
chk(ms)
ms.CBPS = make(map[string]int, 100)
for i := 0; i < flag.NArg(); i++ {
//fmt.Printf("arg %d=|%s|\n", i, flag.Arg(i))
bs, err := bitstream.NewFromFile(flag.Arg(i), "r")
if err != nil {
panic("bad filename")
}
ms.Bitstream = bs
sh := ms.ReadMPEG1Steam(*from, *to)
//fmt.Printf("ms.MpegStats=%#v\n", ms.MpegStats)
if *psf {
iso11172.IterateSlices(sh)
ms.PrintStats()
}
}
}