Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fs = require('fs');
- var ffmpeg = require('ffmpeg-static');
- const os = require('os');
- console.log(ffmpeg.path);
- const { spawn } = require('child_process');
- const Writable = require('stream').Writable;
- const fpath = __dirname + "/uno.mp4"
- const resultpath = __dirname + "/out.png"
- const arguments = `-i pipe: -ss 00:00:02 -vframes 1 ${resultpath}`
- const child = spawn(ffmpeg.path, arguments.split(' '), {
- cwd: os.tmpdir(),
- });
- child.stdin.on('error', (...arg) => {
- console.log('error', arg);
- });
- child.on('exit', code => {
- console.log('exit', code);
- });
- child.stdout.on('data', (data) => {
- console.log(`stdout: ${data}`);
- });
- child.stderr.on('data', (data) => {
- console.log(`stderr: ${data}`);
- });
- const readable = fs.createReadStream(__dirname + '/uno.mp4');
- readable.on('data', (chunk) => {
- console.log(`Received ${chunk.length} bytes of data.`);
- child.stdin.write(chunk);
- });
- readable.on('end', () => {
- console.log('There will be no more data.');
- child.stdin.end()
- });
- // readable.pipe(child.stdin);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement