-
Notifications
You must be signed in to change notification settings - Fork 1
/
flv_parser.py
executable file
·53 lines (40 loc) · 1.05 KB
/
flv_parser.py
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
#!/bin/env python
## flv parser
# Usage: ./flv_parser [path] [-r]
# path: flv file path
# -r: Row mode. Print all tags.
#
##
import sys
import utils
from utils.parser import *
if __name__=="__main__":
raw=False
if len(sys.argv)<2:
print "Usage: %s [flv file] [-r]"%( sys.argv[0] )
sys.exit(0)
for i in range( 2, len(sys.argv) ):
if sys.argv[i]=="-r":
raw=True
fpath = sys.argv[1]
try:
f = open(fpath, "r");
flvheader = FlvHeader()
reader = Reader(f)
# flv header
flvheader.read(reader)
flvheader.show()
# first previous tag size
reader.readUInt32()
while True:
tag = FlvTag()
tag.read( reader )
if raw:
tag.show()
elif tag.get_type()==FlvTag.TAG_SCRIPT: # only print script tag
tag.show()
break
reader.readUInt32() #previous tag size
except EOFError as e:
None
f.close()