Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const fs = require('fs');
- fifo = fs.createReadStream(process.argv[2], { highWaterMark: 4*1024**2, });
- let t0 = Date.now();
- fifo.on('readable', () => {
- const chunk = fifo.read(1024 ** 2);
- if (chunk !== null) {
- let t1 = Date.now();
- process.stdout.write(`${(t1 - t0)/1000.}s, ${1000./(t1 - t0)}fpsn`);
- t0 = t1;
- }
- });
- fifo.on('end', () => {
- process.stdout.write('end');
- });
- import sys
- import numpy as np
- im = np.random.randint(0, 255, size=(1024, 1024)).astype(np.uint8).ravel()
- with open(sys.argv[1], 'wb') as f:
- while True:
- f.write(im.tobytes())
- f.flush()
- import sys
- import numpy as np
- import time
- l = 1024 ** 2
- t0 = time.time()
- with open(sys.argv[1], 'rb') as f:
- while True:
- im = f.read(l)
- t1 = time.time()
- print('{}s, {}fps'.format(t1 - t0, 1/(t1 - t0)))
- t0 = t1
- mkfifo /tmp/video; python producer.py /tmp/video & node reader.js /tmp/video
- mkfifo /tmp/video; python producer.py /tmp/video & python reader.py /tmp/video
Add Comment
Please, Sign In to add comment