Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'on' of undefined in "ffmpegProc.stdout.on" #533

Closed
Buzut opened this issue Apr 27, 2016 · 2 comments
Closed

Cannot read property 'on' of undefined in "ffmpegProc.stdout.on" #533

Buzut opened this issue Apr 27, 2016 · 2 comments

Comments

@Buzut
Copy link

Buzut commented Apr 27, 2016

Hi!

I often end up with this error while trying to encode audio files:

 /home/encoder/node_modules/fluent-ffmpeg/lib/processor.js:493
            ffmpegProc.stdout.on('data', function (data) {
                             ^

TypeError: Cannot read property 'on' of undefined
    at processCB (/home/encoder/node_modules/fluent-ffmpeg/lib/processor.js:493:30)
    at /home/encoder/node_modules/fluent-ffmpeg/lib/processor.js:203:7
    at FfmpegCommand.proto._getFfmpegPath (/home/encoder/node_modules/fluent-ffmpeg/lib/capabilities.js:90:14)
    at FfmpegCommand.proto._spawnFfmpeg (/home/encoder/node_modules/fluent-ffmpeg/lib/processor.js:116:10)
    at /home/encoder/node_modules/fluent-ffmpeg/lib/processor.js:429:12
    at /home/encoder/node_modules/fluent-ffmpeg/node_modules/async/lib/async.js:52:16
    at Immediate._onImmediate (/home/encoder/node_modules/fluent-ffmpeg/node_modules/async/lib/async.js:1206:34)
    at processImmediate [as _immediateCallback] (timers.js:383:17)

As it might help, it's for mp3 encoding. Here's the code:

function encodeAudio(mediaToEncodePath, mediaEncodedPath) {
    var ffmpegCmd = ffmpeg(mediaToEncodePath);
    var ffmpegOpts = ['-ac 2', '-map 0:a', '-map_metadata -1', '-threads 0'];

    ffmpegCmd
    .audioCodec('libmp3lame')
    .audioQuality(1)
    .outputOptions(ffmpegOpts)
    .on('error', function(err) {
        console.error('FFMPEG audio error ' + err.message);
    })
    .on('end', function() {
        […]
    })
    .save(mediaEncodedPath);
}

I don't know if it can have an incidence, but it might be relevent to point out that this function is often called several times in parallel.

@njoyard
Copy link
Member

njoyard commented Apr 29, 2016

This is really weird, I'll try to investigate a bit. Can you tell me your nodejs version, and whether the paths you use are actual physical paths ?

@Buzut
Copy link
Author

Buzut commented Apr 30, 2016

I'm sorry I took so long to answer. I was investigating on my side too. It finally appears that I was launching too many instances of the function in parallel and ended reaching my system stack size limit! Thus, ending with undefined variables and errors.

@Buzut Buzut closed this as completed Apr 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants