openairplay / node_airtunes

node.js AirTunes v2 implementation: stream wirelessly to Apple audio devices.
BSD 2-Clause "Simplified" License
273 stars 84 forks source link

PCM from pipe:1 #27

Closed belaviyo closed 10 years ago

belaviyo commented 10 years ago

Hi,

I am trying to get PCM data from FFmpeg. I found your node_airtunes does the same thing. I was wondering if you can help me out with this:

I am running FFmpeg by -i audiofile -f f32be -ar 44100 -ac 1 pipe:1. So basically I am trying to print the output of ffmpeg in "PCM 32-bit floating-point" format. Then I used the following code to get the data:

    var blob = new Blob([stdout_data], {type: 'application/octet-binary'});
    var reader = new FileReader();
    reader.addEventListener("loadend", function() {
       console.error(Float32Array(reader.result))
    });
    reader.readAsArrayBuffer(blob);

The output I get by running the code does not make sense. The values are not in [-1, 1] limit. I guess I am doing something wrong during the typed array conversion. Any idea what the problem could be?

lperrin commented 10 years ago

Sorry, I have never played with typed arrays before. Are you sure that FFmpeg outputs the correct data? You could parse your output with node.js and use buffer.readFloatBE() to check that.

belaviyo commented 10 years ago

Thanks. According to my tests the problem was that FileReader could not handle the conversion to typed array.