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

ffmpeg exited with code 1: pipe:1: Invalid argument #337

Closed
mbuff24 opened this Issue Nov 12, 2014 · 7 comments

Comments

Projects
None yet
4 participants
@mbuff24

mbuff24 commented Nov 12, 2014

Hey all,

I'm running into an issue where I want an output stream but 'pipe:1' is an invalid argument. I noticed both pipe:0 and pipe:1 in the command, which doesn't seem right.. It also works fine when I use saveToFile()

function makeGif(buffer, cb) {

    var outStream = fs.createWriteStream('test.gif');

    ffmpeg(new BufferStream(buffer))
        .withSize('640x360')
        .addOptions([
            '-vf scale=640:-1',
            '-t 00:00:15',
            '-r 10'
        ])
        .on('start', function(cmd) {
            console.log('Started ' + cmd);
        })
        .on('error', function(err) {
            console.log('An error occurred: ' + err.message);
            cb(err);
        })
        .on('end', function() {
            console.log('Finished encoding');
            cb();
        })
        .writeToStream(outStream, { end: true });
}

Produces this command:

ffmpeg -i pipe:0 -filter:v scale=w=640:h=360 -vf scale=640:-1 -t 00:00:15 -r 10 pipe:1

With this error:

ffmpeg exited with code 1: pipe:1: Invalid argument

I'm also using this version:

"fluent-ffmpeg": "^2.0.0-rc3",

Any idea where I'm going wrong?

Thanks!

@njoyard

This comment has been minimized.

Member

njoyard commented Nov 13, 2014

Hi,
What you did seems fine. Which version of ffmpeg are you using, and on which OS ?

@njoyard

This comment has been minimized.

Member

njoyard commented Nov 13, 2014

Oh, I saw a mistake in your command actually. Basically you should not use both '-vf' as a custom option and a fluent-ffmpeg method that generates filter (because filters must be merged on ffmpeg command line). Actually all the options you passed to addOptions have fluent-ffmpeg equivalents, so you better use them!

ffmpeg(new BufferStream(buffer))
  .size('640x360')
  .videoFilter({ filter: 'scale', options: [640, -1] })
  .duration('0:15')
  .inputFPS(15)

Moreover, I don't get why you use both a size method and a scale filter. You should read the documentation about .size() to achieve what you're trying to do.

@mbuff24

This comment has been minimized.

mbuff24 commented Nov 13, 2014

Thanks @njoyard, but still seeing the same error (ffmpeg exited with code 1: pipe:1: Invalid argument) with the updated function below. Also I'm on Mac OS X 10.9.5, and using ffmpeg: stable 2.4.2.

function makeGif(buffer, cb) {
  var outStream = fs.createWriteStream('test.gif');

  ffmpeg(new BufferStream(buffer))
    .size('640x360')
    .duration('0:15')
    .inputFPS(8)
    .on('start', function(cmd) {
      console.log('Started ' + cmd);
    })
    .on('error', function(err) {
      console.log('An error occurred: ' + err.message);
      cb(err);
    })
    .on('end', function() {
      console.log('Finished encoding');
      cb();
    })
    .writeToStream(outStream, { end: true });
}
@mbuff24

This comment has been minimized.

mbuff24 commented Nov 13, 2014

Silly mistake on my end..

I tried the command ffmpeg -r 8 -i /path/to/big_buck_bunny.mp4 -filter:v scale=w=640:h=360 -t 0:15 pipe:1 and got a better error message "unable to find a suitable output format for 'pipe:1'"

Then I figured out I needed to set the -f, which writes lots of great stuff to stdout!

ffmpeg -r 8 -i /path/to/big_buck_bunny.mp4 -f gif -filter:v scale=w=640:h=360 -t 0:15 pipe:1

So if anyone finds this from google search (or something), this worked for me :)

ffmpeg(new BufferStream(buffer))
    .format('gif')
    .size('640x360')
    .duration('0:15')
    .inputFPS(8)
    .writeToStream(outStream, { end: true });
@njoyard

This comment has been minimized.

Member

njoyard commented Nov 13, 2014

Oh, right, I should have remembered that. When outputting to a file, ffmpeg can determine the format automatically from the filename. But that's not possible using a stream.

Glad you figured it out!

@alekbarszczewski

This comment has been minimized.

alekbarszczewski commented Sep 22, 2015

👍 Thank you!

@henrych4

This comment has been minimized.

henrych4 commented Aug 23, 2018

Similar situation occurs to me when trying to crop image from video. I tried adding .format('jpg') / .format('png') but they all failed with error message: "Output format png is not available".

At the end, adding .addOutputOption([..., '-f image2']) works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment