Go 언어를 공부하면서 만들어 본 간단한 MPEG-2 TS 포맷 확인 프로그램.
TS 파일 경로는 hard coding --;;
느낀건데 easy! rapid! fast coding!
비즈니스 로직 중, customize 가 필요한 부분에 빠른 코딩으로 적절하게 대응할 수 잇을 것 같다.
package main
import (
//"io"
"os"
//"strconv"
"fmt"
)
func main() {
fd, err := os.Open("d:\\양화진 밴드_It's Alright_0.ts")
if err != nil {
panic(err)
}
test_count := 5
buf := make([]byte, 188*test_count)
n, err := fd.Read(buf)
if n == 0 {
panic(err)
}
i := 0
var syncword_lit byte = 0x47
for {
if (i == test_count) {
break;
}
fmt.Printf("%#x ", buf[i*188])
syncword := buf[i*188];
if syncword != syncword_lit {
print("\nno MPEG-2 TS syncword 0x47");
return
}
i++
}
print("\nIt's MPEG-2 TS format")
fd.Close()
}
'Dev > Go' 카테고리의 다른 글
| 공부 - mpeg-2 ts 포맷 확인 샘플 (0) | 2012/08/22 |
|---|
댓글을 달아 주세요