From 0d34a9a6d29b560c92c9b93a3345337e5dcbce01 Mon Sep 17 00:00:00 2001 From: Alex Hultman Date: Tue, 29 Jan 2019 21:13:48 +0100 Subject: [PATCH] At least preload the videoFile --- examples/VideoStreamerSync.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/VideoStreamerSync.js b/examples/VideoStreamerSync.js index e2efe30..dd5066e 100644 --- a/examples/VideoStreamerSync.js +++ b/examples/VideoStreamerSync.js @@ -9,7 +9,8 @@ const fs = require('fs'); const port = 9001; const fileName = '/home/alexhultman/Downloads/Sintel.2010.720p.mkv'; -const totalSize = fs.statSync(fileName).size; +const videoFile = toArrayBuffer(fs.readFileSync(fileName)); +const totalSize = videoFile.byteLength; console.log('WARNING: NEVER DO LIKE THIS; WILL CAUSE HORRIBLE BACKPRESSURE!'); console.log('Video size is: ' + totalSize + ' bytes'); @@ -28,7 +29,7 @@ const app = uWS.SSLApp({ /* Log */ console.log("Copying Sintel video..."); /* Copy the entire video to backpressure */ - res.end(toArrayBuffer(fs.readFileSync(fileName))); + res.end(videoFile); }).get('/*', (res, req) => { /* Make sure to always handle every route */ res.end('Nothing to see here!');