VideoHelp Forum

+ Reply to Thread
Results 1 to 4 of 4
Thread
  1. In ActionScript 3, I use SoundMixer.computeSpectrum() to takes a snapshot of the current sound wave playing on the stage and places it into the specified ByteArray object.

    I want to write the ByteArray into FFMPEG (by std -i pipe:0), but the ByteArray object created is fixed to 512 floating-point values and FFMPEG seem doesn't support that value. The sound in the output is corrupted.

    Here's a part of my code in AS3:

    Code:
    stage.addEventListener(Event.ENTER_FRAME, update);
    function update(e:Event):void{
        var soundBA:ByteArray = new ByteArray();
        SoundMixer.computeSpectrum(soundBA, false, 0);
        process.standardInput.writeBytes(soundBA);
    }
    Quote Quote  
  2. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    You could: truncate your float to a precision that ffmpeg DOES support, probably the 64bit one, as that is highest. 64bit float is VERY VERY high precision/dynamic range, so should not be losing any value of data.

    Though on 2nd thought, it sounds like the "512" bytes is the stereo packet size, with each byte being a (-1 to +1) sample. And the example shown on that page mentions using 32bit float, so maybe that's the one you should choose. Try both endian versions - one will be much better than the other ("signal" vs. "noise/static").

    Actionscript 3, wow.


    Scott
    Quote Quote  
  3. Originally Posted by Cornucopia View Post
    You could: truncate your float to a precision that ffmpeg DOES support, probably the 64bit one, as that is highest. 64bit float is VERY VERY high precision/dynamic range, so should not be losing any value of data.

    Though on 2nd thought, it sounds like the "512" bytes is the stereo packet size, with each byte being a (-1 to +1) sample. And the example shown on that page mentions using 32bit float, so maybe that's the one you should choose. Try both endian versions - one will be much better than the other ("signal" vs. "noise/static").

    Actionscript 3, wow.


    Scott
    Hornestly, I don't know whether "512 floating-point values" is the packet size or the bit-depth of the sound sample.

    If it is the packet size (so it point out the "duration"/ how many samples in one snapshot ByteArray), how can I know the bit-depth?

    The document doesn't tell me clearly about this. Although its example shown that "The sound bytes are read as 32-bit floating-point number from the byte stream", it can be forced to do so and I don't know how the raw audio bit-depth is.

    Do you have any ideas about this?
    Quote Quote  
  4. There is no way that these are 512 bit floating point data types, cpu's are not capable, under normal circumstances, of processing 512 bit data types, regardless of whether or not it's an int or a float.

    For the record:

    short = 16 bit
    int = 32 bit
    long = 32 bit
    float = 32 bit
    double = 64 bit

    Then you have the SIMD data types which for SSE are 128 bit, AVX are 256 bit AVX-512 are 512 bit.

    I think you are confusing 2 very different things.
    Quote Quote  



Similar Threads