-
Notifications
You must be signed in to change notification settings - Fork 8
/
extractHeader.py
executable file
·51 lines (43 loc) · 1.44 KB
/
extractHeader.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
#!/usr/bin/env python
#
# Copyright 2009 Claudio Pisa (claudio dot pisa at uniroma2 dot it)
#
# This file is part of SVEF (SVC Streaming Evaluation Framework).
#
# SVEF is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# SVEF is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with SVEF. If not, see <http://www.gnu.org/licenses/>.
#
import sys
from nalulib import *
if(len(sys.argv) < 4):
print "Usage: %s <trace file> <H.264 file> <Output H.264 file>" % sys.argv[0]
sys.exit(1)
tracefilename = sys.argv[1]
h264filename = sys.argv[2]
outh264filename = sys.argv[3]
tracefile = open(tracefilename, 'rb', 0)
h264 = open(h264filename, 'rb', 0)
outh264 = open(outh264filename, 'wb', 0)
for line in tracefile:
try:
nalu = NALU(line)
if nalu.packettype != "SliceData":
#take the nalu from the 264 file and append it to the outfile
h264.seek(nalu.id)
data = h264.read(nalu.length)
outh264.write(data)
except NALUException:
pass
tracefile.close()
h264.close()
outh264.close()