diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-02-22 18:12:34 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-02-22 18:12:34 +0100 |
commit | 320ba6c22da9b7c06cbf4e6ec2cc183fcc27d9f0 (patch) | |
tree | e5b511e61d8f99e29eae5c9fc29bc3b122c00a85 | |
parent | d20204414d96cfd6f1ab100df13b0aca3088f5ea (diff) | |
download | etisnoop-320ba6c22da9b7c06cbf4e6ec2cc183fcc27d9f0.tar.gz etisnoop-320ba6c22da9b7c06cbf4e6ec2cc183fcc27d9f0.tar.bz2 etisnoop-320ba6c22da9b7c06cbf4e6ec2cc183fcc27d9f0.zip |
Add ETI duplicate frame removal helper tool
-rwxr-xr-x | remove-duplicate-frames.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/remove-duplicate-frames.py b/remove-duplicate-frames.py new file mode 100755 index 0000000..c6451d8 --- /dev/null +++ b/remove-duplicate-frames.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python +# +# This script removes duplicate frames from a RAW ETI file. +# It reads FCT from etisnoop output and only copies the +# frames if the FCT is increasing by one. +# +# usage: +# etisnoop -v -i in.eti | remove-duplicate-frames.py in.eti out.eti + +import sys +import re + +regex = re.compile(r'Frame Count \[([0-9]+)\]') + +if len(sys.argv) < 3: + print("usage: etisnoop -vi in.eti | {} in.eti out.eti".format(sys.argv[0])) + sys.exit(1) + + +eti_in = open(sys.argv[1], "rb") +eti_out = open(sys.argv[2], "wb") + +lastfct = -1 +while True: + line = sys.stdin.readline() + if line == '': + break + + fct = 0 + + m = regex.search(line) + if m is None: + continue + else: + fct = int(m.groups()[0]) + + if lastfct == 0 and fct == 249: + print("Ignore {} duplicate rollover".format(fct)) + eti_in.read(6144) + elif fct > lastfct: + print("Take {}".format(fct)) + eti_out.write(eti_in.read(6144)) + lastfct = fct + elif lastfct == 249 and fct == 0: + print("Take {} because rollover".format(fct)) + eti_out.write(eti_in.read(6144)) + lastfct = fct + else: + print("Ignore {}".format(fct)) + eti_in.read(6144) + |