filoe / cscore

An advanced audio library, written in C#. Provides tons of features. From playing/recording audio to decoding/encoding audio streams/files to processing audio data in realtime (e.g. applying custom effects during playback, create visualizations,...). The possibilities are nearly unlimited.
Other
2.15k stars 451 forks source link

Question: Real-time AAC encoding of data from SoundInSource? #388

Closed jeremywho closed 4 years ago

jeremywho commented 4 years ago

I want to take the data coming in via microphone and encode it to AAC to be sent over the network.

The samples make it easy to understand how to get pcm data via the mic, but I'm having trouble understanding if its possible to then encode those bytes to AAC. MFE or any other available framework would be fine.

Is this possible?

Ambusy commented 4 years ago

There is a MediaFoundationEncoder.CreateAACEncoder(stereoSource.WaveFormat, filename). You would have to modify the encoder not to write to a file but to the internet. But perhaps Filoe knows a better solution. Look into the RecorderToWma sample.

filoe commented 4 years ago

The MediaFoundationEncoder can store data to a stream. You can implement any stream which will handle the Write calls correctly to stream it to any network.