diff --git a/lib/cea608-parser.js b/lib/cea608-parser.js index a289a21..8a79b66 100644 --- a/lib/cea608-parser.js +++ b/lib/cea608-parser.js @@ -834,6 +834,9 @@ logger.setTime(t); for (var i = 0 ; i < byteList.length ; i+=2) { + t = this.lastTime + 0.5 * i * 1001 / 30000; + logger.setTime(t); + a = byteList[i] & 0x7f; b = byteList[i+1] & 0x7f; diff --git a/lib/scc-parser.js b/lib/scc-parser.js index 2a55b0b..a24ed8f 100644 --- a/lib/scc-parser.js +++ b/lib/scc-parser.js @@ -40,7 +40,7 @@ var SccParser = function(filePath, processor, field) { SccParser.prototype.parse = function() { var lineData, - lines = fs.readFileSync(this.filePath, 'utf8').split("\n"); + lines = fs.readFileSync(this.filePath, 'utf8').split(/\r?\n/); this.nrLinesParsed = 0; @@ -70,7 +70,7 @@ SccParser.prototype.parseDataLine = function(line) if (!line) { return null; } - var lineParts = line.split(" "); + var lineParts = line.split(/\s/); var timeData = lineParts[0]; var ceaData = []; var a, b, fourHexChars; @@ -86,8 +86,9 @@ SccParser.prototype.parseDataLine = function(line) parts[2] = last_parts[0]; parts[3] = last_parts[1]; } - return parseInt(parts[0])*3600 + parseInt(parts[1])*60 + parseInt(parts[2])+ - parseInt(parts[3])/30.0; + return + (30 * (60 * (60 * parseInt(parts[0]) + parseInt(parts[1])) + parseInt(parts[2])) + parseInt(parts[3])) + * 1001 / 30000; }; for (var i=1 ; i < lineParts.length ; i++) {