From 320ba6c22da9b7c06cbf4e6ec2cc183fcc27d9f0 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sun, 22 Feb 2015 18:12:34 +0100 Subject: Add ETI duplicate frame removal helper tool --- remove-duplicate-frames.py | 51 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 remove-duplicate-frames.py 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) + -- cgit v1.2.3