Reputation: 33
var fp = 'ffprobe ' + fileName + ' -show_streams | grep '
var width = exec(fp+'width', function(err, stdout, stderr){
return stdout;
});
alert(stdout + 'random example');
how do I get the stdout 'out' of the process so that I can use it later.
Upvotes: 3
Views: 5014
Reputation: 1426
None of the answers above worked for me. This did though.
var probeCommand = 'rtsp://xx.xx.xx.xx/axis-media/media.3gp'
exec('ffprobe '+probeCommand+' | echo ',function(err,stdout,stderr){
console.log(stdout+stderr)
})
Upvotes: 0
Reputation: 25572
Node's exec
function is asynchronous. This means that there is no guarantee that code below the exec
call will wait until the child process finishes to run. To execute code once the process quits, then, you must provide a callback which deals with the results. Your code can branch off from there:
var fp = 'ffprobe ' + fileName + ' -show_streams | grep ';
var width = exec(fp+'width', function(err, stdout, stderr){
console.log(stdout);
// ... process stdout a bit ...
afterFFProbe(stdout);
});
function afterFFProbe(output) {
// your program continues here
}
Upvotes: 6
Reputation: 143
I think this might work:
var output = "";
var fp = 'ffprobe ' + fileName + ' -show_streams | grep '
var width = exec(fp+'width', function(err, stdout, stderr){
this.output = stdout;
});
alert(output + 'random example');
Upvotes: -1
Reputation: 792
If I'm understanding you correctly:
var fp = 'ffprobe ' + fileName + ' -show_streams | grep ',
value,
width = exec(fp+'width', function(err, stdout, stderr) {
value = stdout;
return stdout;
});
alert(value + 'random example');
Upvotes: -1