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

Process is not killing it self on error (or Timeout). #482

Open
mh4ck opened this issue Dec 10, 2015 · 6 comments
Open

Process is not killing it self on error (or Timeout). #482

mh4ck opened this issue Dec 10, 2015 · 6 comments
Labels
Milestone

Comments

@mh4ck
Copy link

mh4ck commented Dec 10, 2015

The ffmpeg process is not killing itself on an error the error event, and kill() is not working.
Does anybody know how to fix this?

I think the processes stay available on reaching the timeout.
After a timeout the 'error' event is called, in this i kill the process but the process in linux "ps"
is still available.

Is there another way to get the process id or something to kill it?

var ffmpegProc = new ffmpeg({source:videoPath, timeout: 20})
                  .duration(900) //15 min
                  .format('mp3')
                  .on('error', function(err, stdout, stderr) {

                    activeConversions--;
                    fs.exists(videoPath, function(exists) {

                      if(exists) {

                       fs.unlink(videoPath, exports.handleError);
                      }
                    });
                    if(!_.isUndefined(currentConversions[id]))delete currentConversions[id];
                    if(!_.isUndefined(ffmpegProc.kill))ffmpegProc.kill();
                    exports.handleError({err:err});
                  })
                  .on('start', function(pinfo) {

                    activeConversions++;
                    currentConversions[id] = {
                      progressName: 'Converting to MP3', 
                      progressValue: 0, 
                      title: info.title
                    };
                  })
                  .on('end', function() {

                    activeConversions--;
                    fs.exists(videoPath, function(exists) {

                      if(exists) {

                       fs.unlink(videoPath, exports.handleError);
                      }
                    });
                    if(!_.isUndefined(currentConversions[id]))delete currentConversions[id];
                  })
                  .pipe(writeStream, {end: true});
@njoyard
Copy link
Member

njoyard commented Dec 10, 2015

Getting the pid won't enable you to do anything .kill does not.
What is the error you're getting when ffmpeg is not killed ?

@njoyard
Copy link
Member

njoyard commented Dec 10, 2015

Also, take care with your activeConversions : you can have an 'error' event without any 'start' event in some corner cases.

@mh4ck
Copy link
Author

mh4ck commented Dec 10, 2015

I get the "timeout" (Error: process ran into a timeout (20s)) error - after that the process is not killed.

@njoyard
Copy link
Member

njoyard commented Dec 11, 2015

What is your OS and which versions of fluent-ffmpeg/ffmpeg/node.js are you using?

@mh4ck
Copy link
Author

mh4ck commented Dec 11, 2015

OS: Debian
NodeJS: v0.12.7

@njoyard njoyard added the WIP label Feb 21, 2016
@njoyard njoyard added this to the 2.1.0 milestone Mar 16, 2016
@njoyard njoyard modified the milestones: 2.2.0, 2.1.0 May 1, 2016
@Kostanos
Copy link

This is how I kill it:

let self = this;
self.camera
        .on('error', (err, stdout, stderr) => {
          error('Video stream closed error(%s) stderr(%s)', err.message, stderr);
          reject('Video stream closed ' + stderr);
          if (self.camera) {
            self.camera.kill();
            self.camera = null;
            self.stream = null;
          }
        });

My question is why do I have timeout every 30 seconds. I found that other people reported 600 seconds timeout some other even 20 seconds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants