Open alexcroox opened 9 years ago
What you have seems right having looked at the ffmpeg Readme. It talks about passing a Readable stream (which the camera.vid
would be) and then chaining the inputOptions
method.
What happens when you run the code above?
Sorry for the delay just got a rPi 2 so thought I'd get everything set up on there before continuing!
The error I get is
/home/pi/node_modules/fluent-ffmpeg/lib/options/custom.js:43
throw new Error('No input specified');
So not sure I'm passing the input correctly, or it doesn't like camera.vid as an input.
Can you post the full stacktrace - I can't work out where line 43 of custom.js is being called from.
Thanks :)
Hey - so what happens if you:
ffmpeg().addInput(camera.vidProc).inputOptions(...)
If this does not work - can you create a file from the camera (for example 'testfile.avi') and then try this:
ffmpeg().addInput('/tmp/testfile.avi').inputOptions(...)
This will test for sure if its an issue with a stream vs a static file.
I'm starting to wonder if there is a bigger problem with my setup at hand here
var fs = require('fs');
var file = fs.createWriteStream('/tmp/testfile.avi');
var video = raspivid();
video.pipe(file);
errors out
video.pipe(file);
^
TypeError: undefined is not a function
at Object.<anonymous> (/home/pi/pi-node.js:32:7)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
Hmmm odd - I would do 2 things:
a) run raspivid
on your PI command line and check it is there
b) use child_process.spawn directly - the core of this library is a tiny wrapper:
var fs = require('fs');
var child = require('child_process');
var video_process = child.spawn('raspivid', args, {
stdio: ['ignore', 'pipe', process.stderr]
});
var file = fs.createWriteStream('/tmp/testfile.avi');
video_process.stdout.pipe(file);
Lets ignore this repo for a moment whilst trying to find what the problem is :-)
Regarding above args
would be an array of command line arguments passed to raspivid
Yer raspivid is definitely OK as my current implementation works fine:
camera.process = child.spawn('./cam.sh', []);
cam.sh
raspivid -n -mm matrix -w 320 -h 240 -fps 18 -g 100 -t 0 -b 5000000 -o - | ffmpeg -y -f h264 -i - -c:v copy -map 0:0 -f flv -rtmp_buffer 100 -rtmp_live live "rtmp://stream.sidg.tl/big/gun-turret"
This works absolutely fine. I'll try creating the test file as you mentioned
perhaps its to do with the stdio
pipe arrangement - when you do the test file try doing with empty args like your example also...
was this resolved?
I'm using https://github.com/fluent-ffmpeg/node-fluent-ffmpeg and I'd like to pipe the output from raspivid into ffmpeg.
I'm not sure how to go about this as ffmpeg requires an input.
camera.vid = raspivid({ width: 320, height: 240, "-fps": 18, "-b": 5000000, "-mm": "matrix", "-g": 100, "-t": 0 });
camera.stream = ffmpeg(camera.vid).inputOptions(["-y", "-f", "h264", "-video_size", "320x240", "-i", "-", "-c:v", "copy", "-map", "0:0", "-f", "flv", "-rtmp_buffer", "100", "-rtmp_live", "live", "rtmp://example.com/big/test"]));