Getting audio from LibVLC
Posted: 18 Mar 2016 06:13
I'm using ffmpeg to stream video and audio from a WebCam over a network then using a modified version of Hyper VLC (a C# wrapper around LibVLC) to get it into Unity. After a bit of work I've managed to get the video working well, but HyperVLC doesn't handle audio so I'm trying to add it myself and I can't figure out how to get the audio data out of LibVLC.
I initialise the audio similar to the video using libvlc_audio_set_format and libvlc_audio_set_callbacks, giving it OnPlayAudio(void* data, void* samples, uint count, long pts) as the play callback. But I can't figure out how to use the parameters that method gives me. "data" is always null, and I've tried marshalling "samples" into a float array, but it only gives exponentially small values and NaNs.
I need to get the audio as a float array (with all values between 0 and 1 I believe) to give to Unity. Any help would be greatly appreciated.
I initialise the audio similar to the video using libvlc_audio_set_format and libvlc_audio_set_callbacks, giving it OnPlayAudio(void* data, void* samples, uint count, long pts) as the play callback. But I can't figure out how to use the parameters that method gives me. "data" is always null, and I've tried marshalling "samples" into a float array, but it only gives exponentially small values and NaNs.
I need to get the audio as a float array (with all values between 0 and 1 I believe) to give to Unity. Any help would be greatly appreciated.