node.js - FFmpeg Stream RTSP input and save to file at the same time using nodejs -
i using node-rtsp-stream module stream rtsp web nodejs. streaming rtsp source ffmpeg, example rtsp source - example
i know can save 1 or many inputs many outputs dont know if there option stream input , save file @ same time without executing 2 process of ffmpeg.
following example able stream rtsp source
ffmpeg -i rtsp-url -rtsp_transport tcp -f mpeg1video -b:v 800k -r 30
on module that:
this.stream = child_process.spawn("ffmpeg", [ "-i", this.url, "-rtsp_transport", "tcp",'-f', 'mpeg1video', '-b:v', '800k', '-r', '30', '-'], { detached: false }); ff =child_process.spawn("ffmpeg", [ "-i", this.url, '-b:v', '800k', '-r', '30', '1.mp4'], { detached: false }); this.inputstreamstarted = true; this.stream.stdout.on('data', function(data) { return self.emit('mpeg1data', data); }); this.stream.stderr.on('data', function(data) { return self.emit('ffmpegerror', data); });
as can see using 2 process of ffmpeg want if faced issue , solve 1 command ( process ), suggestions. how stream rtsp source , save file @ same time.
for more information module use: node-rtsp-stream
try code: (it read rtsp , save jpg file (overwrite every 3 seconds))
var fs = require('fs'); var spawn = require('child_process').spawn; var rtspuri = 'rtsp://wowzaec2demo.streamlock.net/vod/mp4:bigbuckbunny_115k.mov'; var fps = 1/3; //avconv -i rtsp://wowzaec2demo.streamlock.net/vod/mp4:bigbuckbunny_115k.mov \ // -r 1/3 -an -y -update 1 test.jpg var ffmpeg = spawn('avconv', ['-i',rtspuri,'-r',fps,'-an','-y','-update','1','test.jpg']); // var ffmpeg = spawn('avconv', // ['-i','rtsp://wowzaec2demo.streamlock.net/vod/mp4:bigbuckbunny_115k.mov', // '-r','1/3','-an','-y','-update','1','test.jpg']); ffmpeg.stdout.on('data', function (data) { console.log('stdout: ' + data); }); ffmpeg.stderr.on('data', function (data) { console.log('stderr: ' + data); }); ffmpeg.on('close', function (code) { console.log('child process exited code ' + code); });
Comments
Post a Comment