-
Notifications
You must be signed in to change notification settings - Fork 8
/
splitLongNalus.py
executable file
·66 lines (55 loc) · 1.97 KB
/
splitLongNalus.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
54
55
56
57
58
59
60
61
62
63
64
#!/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
import commands
import tempfile
import os
from nalulib import *
if(len(sys.argv) < 3):
print """
For each line of a BitstreamExtractor-generated trace file, find
NALUs that exceed a fixed length and split them in two NALUs.
Usage: %s <BitsreamExtractor generated trace> <maximum length> > sendingtrace.txt
Where:
<BitstreamExtractor generated trace>: the trace file obtained by using
the "-pt" option of the BitstreamExtractor executable using as argument
the sent H.264 file, or from the purgeLastGOP.py script.
For example:
$ BitstreamExtractorStatic -pt originaltrace.txt foreman.264
Example: $ %s originaltrace.txt 65000 > originaltrace-frameno.txt
""" % (os.path.basename(sys.argv[0]), os.path.basename(sys.argv[0]))
sys.exit(1)
originaltraceptfilename = sys.argv[1]
maxlen = int(sys.argv[2])
# load lines from the original trace file
originaltracefile = open(originaltraceptfilename)
for line in originaltracefile:
try:
nalu = NALU(line)
if nalu.length == -1:
pass
elif nalu.length <= maxlen:
print nalu
elif nalu.length > maxlen:
for n in nalu.meiosis(maxlen):
print n
except NALUException:
pass
originaltracefile.close()