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

'Error opening filters' on mp4 stream #353

Closed
chinedufn opened this Issue Jan 9, 2015 · 7 comments

Comments

Projects
None yet
5 participants
@chinedufn

chinedufn commented Jan 9, 2015

Hey all,

I'm trying to pipe a video to an output stream with a maximum duration, but I'm getting an "Error opening filters!" issue.

After trying the solution from #337 , I am still unable to get it to work.

Here is my code

        var w = fs.createWriteStream('out.mp4');
        ffmpeg(data.file)
        .format('mp4')
        .size('640x360')
        .duration('0:15')
        .inputFPS(15)
        .on('error', function(err) {
          console.log('An error occured: ' + err.message);
        })
        .on('end', function() {
          console.log('Processing finished');
        })
        .writeToStream(w, {end:true});

For potential reference:

  • My readable stream is from a multipart file upload. I'm using Hapi (which uses node-multiparty).
  • data.file.pipe(w) works as expected
  • I am running ffmpeg version 2.5.2

Am I missing something? Any help is very appreciated.

Thank you!

@njoyard

This comment has been minimized.

Member

njoyard commented Jan 15, 2015

You may get a more detailed error report by logging ffmpeg stdout and stderr. Those are available as additional arguments to the 'error' handler.

@njoyard njoyard added the Needs info label Jan 15, 2015

@joshuamcginnis

This comment has been minimized.

joshuamcginnis commented Feb 3, 2015

@njoyard I'm experiencing the same error, but have some additional feedback. Hopefully this provides some additional clues needed to resolve this.

My configuration:

  var stream = fs.createReadStream('./samples/' + req.params.video);

  var proc = ffmpeg(stream)

    .format('mp4')
    .size('320x?')
    .videoBitrate('512k')
    .videoCodec('libx264')
    .fps(24)
    .audioBitrate('96k')
    .audioCodec('aac')
    .audioFrequency(22050)
    .audioChannels(2)

    .on('error', function(err, stdout, stderr) {
      console.log('an error happened: ' + err.message, stdout, stderr);
    })

    .pipe(res, { end:true });

The Error:

an error happened: ffmpeg exited with code 1: Error opening filters!
 null ffmpeg version N-69497-g9d7ae72 Copyright (c) 2000-2015 the FFmpeg developers
  built with Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
  configuration: --prefix=/usr/local --enable-gpl --enable-nonfree --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-libfaac --enable-libfdk-aac
  libavutil      54. 18.100 / 54. 18.100
  libavcodec     56. 21.102 / 56. 21.102
  libavformat    56. 19.100 / 56. 19.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5.  9.103 /  5.  9.103
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fe9c2812800] overread end of atom 'colr' by 1 bytes
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fe9c2812800] stream 0, offset 0xa8: partial file
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fe9c2812800] Could not find codec parameters for stream 0 (Video: h264 (avc1 / 0x31637661), none(tv, bt709), 560x320, 465 kb/s): unspecified pixel format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'pipe:0':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isomavc1
    creation_time   : 2010-03-20 21:29:11
    encoder         : HandBrake 0.9.4 2009112300
  Duration: 00:00:05.57, bitrate: N/A
    Stream #0:0(und): Video: h264 (avc1 / 0x31637661), none(tv, bt709), 560x320, 465 kb/s, 30 fps, 30 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      creation_time   : 2010-03-20 21:29:11
      encoder         : JVT/AVC Coding
    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 83 kb/s (default)
    Metadata:
      creation_time   : 2010-03-20 21:29:11
[buffer @ 0x7fe9c0d190c0] Unable to parse option value "-1" as pixel format
    Last message repeated 1 times
[buffer @ 0x7fe9c0d190c0] Error setting option pix_fmt to value -1.
[graph 0 input from stream 0:0 @ 0x7fe9c0d19160] Error applying options to the filter.
Error opening filters!
@njoyard

This comment has been minimized.

Member

njoyard commented Feb 3, 2015

First, don't use streams both for input and output. This will deadlock eventually.
Second, can you please try doing the same from command line to see if it works ?

@blvz

This comment has been minimized.

blvz commented Feb 12, 2015

I was running into a similar issue, but then I've found this:
http://stackoverflow.com/questions/25411836/ffmpeg-doesnt-work-with-mp4-and-stdout

@njoyard

This comment has been minimized.

Member

njoyard commented Feb 24, 2015

Yup, always forget that one. mp4 requires seekable output, so you either have to write mp4 to a file, or write an other format to a pipe.

Feel free to reopen if you need further help.

@njoyard njoyard closed this Feb 24, 2015

@rknell

This comment has been minimized.

rknell commented Mar 8, 2015

To all those who want to get mp4 working using a stream and piping it to an express response object this is how its done without writing it to a file: (i have used the example code from the express-stream.js in node-ffmpeg-fluent and modified it to suit). You can't seek for a number of reasons but it works!

var express = require('express'),
  ffmpeg = require('../index');

var app = express();

app.use(express.static(__dirname + '/flowplayer'));

app.get('/', function(req, res) {
  res.send('index.html');
});

app.get('/video/:filename', function(req, res) {
  res.contentType('mp4');
  // make sure you set the correct path to your video file storage
  var pathToMovie = "/path/to/myvideo.avi";
  var proc = ffmpeg(pathToMovie)
    .format("mp4")
    .size("320x?")
    .addOptions([
      "-movflags frag_keyframe+faststart"
    ])
    // setup event handlers
    .on('end', function() {
      console.log('file has been converted succesfully');
    })
    .on('error', function(err) {
      console.log('an error happened: ' + err.message);
    })
    // save to stream
    .pipe(res, {end:true});
});

app.listen(4000);

And then in the html:

<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
        <title>node-fluent-ffmpeg</title>
    </head>
    <body>

        <video src="/video/your_movie.avi" autoplay></video>
    </body>
</html>
@njoyard

This comment has been minimized.

Member

njoyard commented Mar 9, 2015

Thanks !

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