title: Converting audio with sox in nodejs
body: <p>I have made sure that all that sox needs to function is installed, and I've also installed the <a href="https://www.npmjs.com/package/sox" rel="nofollow">sox</a> package for node. Yet, this does not seem to work.</p>
  
  <pre><code>function encode(file, destination, quality) {
    return new Promise((resolve, reject) =&gt; {
      console.log(destination)
  
      let job = sox.transcode(file, destination, {
          sampleRate: 44100,
          format: 'mp3',
          bitRate: quality * 1024,
      })
  
      job.on('src', function(info) {
        console.log(info)
      });
  
      job.on('progress', (amountDone, amountTotal) =&gt; {
        console.log("progress", amountDone, amountTotal);
      });
  
      job.on('error', (err) =&gt; {
        reject('Could not transcode mp3.')
      })
  
      job.on('end', () =&gt; {
        resolve('mp3 transcoded.')
      })
  
      console.log(job)
    })
  }
  </code></pre>
  
  <p>The <code>console.log</code> at the end logs:</p>
  
  <pre><code>Transcode {
    domain: null,
    _events:
     { src: [Function],
       progress: [Function],
       error: [Function],
       end: [Function] },
    _eventsCount: 4,
    _maxListeners: undefined,
    inputFile: 'C:\\Users\\User\\Documents\\App\\Media\\media\\uploads\\audio/2016/269/1/0//10c746ef62374c6ab1f2ecfc36705618/original.mp3',
    outputFile: 'C:\\Users\\User\\Documents\\App\\Media\\media\\uploads\\audio/2016/269/1/0//10c746ef62374c6ab1f2ecfc36705618/128.mp3',
    options:
     { sampleRate: 44100,
       format: 'mp3',
       bitRate: 196608,
       channelCount: 2,
       compressionQuality: 5 } }
  </code></pre>
  
  <p>There are no errors, so I wonder if something here is failing silently. Identifying a file works just fine:</p>
  
  <pre><code>let original = (path + 'original.mp3')
  
  sox.identify(original, function(err, info) {
   if (err) {
     console.log(err)
     throw(err)
   }
   if (info.format !== 'mp3') {
     throw('File must be mp3!')
   }
   console.log(info) // {format: 'mp3', ..}
  });
  </code></pre>
  
  <p>The above code works just fine. but <code>sox.transcode</code> does not.</p>