From 9b982b55d9e47c82cff58fdc3fa777286ca063b5 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Fri, 4 Jan 2019 16:03:53 -0800 Subject: [PATCH] Fix timing alignment due to codecs A file opened with copen can return more characters than requested from a read() call. This can result in the playback running fast. To correct this, read into a buffer and then pull from the buffer as directed by the timing file. --- bin/TermRecord | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/TermRecord b/bin/TermRecord index 758ee34..7aec1d2 100755 --- a/bin/TermRecord +++ b/bin/TermRecord @@ -133,8 +133,12 @@ def scriptToJSON(scriptf, timing=None): with closing(scriptf): scriptf.readline() # ignore first header line from script file offset = 0 + buf = '' for t in timing: - data = escapeString(scriptf.read(t[1])) + while (len(buf) < t[1]): + buf += scriptf.read(t[1]) + data = escapeString(buf[:t[1]]) + buf = buf[t[1]:] offset += t[0] ret.append((data, offset)) return dumps(ret)