title: running ffmpeg via nodejs error
body: <p>I'm trying to run ffmpeg from node, and I'm getting an error. Here is the code</p>
  
  <pre><code>var exec = require('child_process').exec;
  
  var cmd = '/home/ubuntu/bin/ffmpeg -i /home/ubuntu/input.flv -s 640x480 -y -codec:a aac -b:a 44.1k -r 15 -b:v 1000k -codec:v h264 -f mp4 /home/ubuntu/output.mp4';
  
  exec(cmd, function(err, stdout, stderr) {
      if (err) console.log('err:\n' + err);
      if (stderr) console.log('stderr:\n' + stderr);
      console.log('stdout:\n' + stdout);
  });
  </code></pre>
  
  <p>When I run this node script, I get the following errors: </p>
  
  <pre><code>err:
  Error: Command failed: /home/ubuntu/bin/ffmpeg -i /home/ubuntu/input.flv -s 640x480 -y -codec:a aac -b:a 44.1k -r 15 -b:v 1000k -codec:v h264 -f mp4 /home/ubuntu/output.mp4
  ffmpeg version N-83323-g126e965 Copyright (c) 2000-2017 the FFmpeg developers
    built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
    configuration: --prefix=/home/ubuntu/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/ubuntu/ffmpeg_build/include --extra-ldflags=-L/home/ubuntu/ffmpeg_build/lib --bindir=/home/ubuntu/bin --enable-gpl --enable-libopus --enable-libvpx --enable-libvorbis --enable-libmp3lame --enable-libfdk-aac --enable-libx264 --enable-nonfree
    libavutil      55. 45.100 / 55. 45.100
    libavcodec     57. 75.100 / 57. 75.100
    libavformat    57. 66.101 / 57. 66.101
    libavdevice    57.  2.100 / 57.  2.100
    libavfilter     6. 72.100 /  6. 72.100
    libswscale      4.  3.101 /  4.  3.101
    libswresample   2.  4.100 /  2.  4.100
    libpostproc    54.  2.100 / 54.  2.100
  /home/ubuntu/input.flv: Invalid data found when processing input
  
  stderr:
  ffmpeg version N-83323-g126e965 Copyright (c) 2000-2017 the FFmpeg developers
    built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
    configuration: --prefix=/home/ubuntu/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/ubuntu/ffmpeg_build/include --extra-ldflags=-L/home/ubuntu/ffmpeg_build/lib --bindir=/home/ubuntu/bin --enable-gpl --enable-libopus --enable-libvpx --enable-libvorbis --enable-libmp3lame --enable-libfdk-aac --enable-libx264 --enable-nonfree
    libavutil      55. 45.100 / 55. 45.100
    libavcodec     57. 75.100 / 57. 75.100
    libavformat    57. 66.101 / 57. 66.101
    libavdevice    57.  2.100 / 57.  2.100
    libavfilter     6. 72.100 /  6. 72.100
    libswscale      4.  3.101 /  4.  3.101
    libswresample   2.  4.100 /  2.  4.100
    libpostproc    54.  2.100 / 54.  2.100
  /home/ubuntu/input.flv: Invalid data found when processing input
  
  stdout:
  </code></pre>
  
  <p>But when I run </p>
  
  <pre><code>/home/ubuntu/bin/ffmpeg -i /home/ubuntu/input.flv -s 640x480 -y -codec:a aac -b:a 44.1k -r 15 -b:v 1000k -codec:v h264 -f mp4 /home/ubuntu/output.mp4
  </code></pre>
  
  <p>straight in the terminal, It works flawlessly.  I think it has to do with how node runs the command but all my google searching has returned zero useful results. Any help is greatly appreciated. </p>