rainbowcreatures / FlashyWrappers

AIR / Flash video recording SDK
17 stars 10 forks source link

Do you have example work with addAudioFrame function? #12

Closed rubel closed 7 years ago

rubel commented 7 years ago

Can you please provide a sample work with addAudioFrame function?

rainbowcreatures commented 7 years ago

Sorry I don't have time to add more samples currently, but the idea is to either add small chunks of audio by using that or a big one, like an audio track, at the beginning. If its an audio track, the ANE will try to chop it internally and feed it together with video frames.

You can kind of find a "sample" of the code in the AS3 ANE wrapper itself, where addAudioFrame is used internally to record microphone:

  // take the audio samples from microphone and add them into myEncoder
  private function sndDataMic(event:SampleDataEvent):void {           
      if (event.data.bytesAvailable > 0)
      {
          while(event.data.bytesAvailable > 0)
          {
              samplesMic.writeFloat(event.data.readFloat());
          }
      }
      if (samplesMic.length >= 8192) {
          samplesMic.position = 0;
          addAudioFrame(samplesMic);
          samplesMic.length = 0;
      }
  }