Opus codec not working properly

Here’s the code and already added the Voice module.

FVoiceModule* myVoiceModule2;
TSharedPtr myVoiceEncoder2 = NULL;

myVoiceModule2 = &FVoiceModule::Get();
myVoiceEncoder2 = myVoiceModule2->CreateVoiceEncoder(48000, 2, EAudioEncodeHint::VoiceEncode_Audio);
myVoiceEncoder2->DumpState();
UE_LOG(LogVoiceEncode, Warning, ■■■■■■■■■■."));
myVoiceEncoder2->SetBitrate(32000);
myVoiceEncoder2->SetComplexity(10);
myVoiceEncoder2->DumpState();
UE_LOG(LogVoiceEncode, Warning, ■■■■■■■■■■."));
TArray<uint8> DecompressedVoiceBuffer;
TArray<uint8> CompressedVoiceBuffer;
DecompressedVoiceBuffer.Empty(10000);
CompressedVoiceBuffer.Empty(10000);
uint32 compressedSize;
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, FString::FromInt(960));
int32 LastRemainderSize = myVoiceEncoder2->Encode(DecompressedVoiceBuffer.GetData(), 960, CompressedVoiceBuffer.GetData(), compressedSize);
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Blue, FString::FromInt(compressedSize));
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Red, FString::FromInt(LastRemainderSize));

There’s no error, but the compressedSize always be 0.
Did I miss something?

I’m making a custom VOIP system and got stuck in here. Somebody help me? There’s really not any documentation.

I simplified the problem on this thread. Here’s my source code in case you want to see it. I used Wasapi to capture voice data but could not encode it.
myVOIP.cpp (14.5 KB)
myVOIP.h (2.2 KB)

Okay, I give up…
I’ll add the Opus c files to my project. And skip the APIs Epic provides.

I was reading the OPUS source for the past 3 hours and i have the solution.

The real solution though is that the Encode function expects the length of the available buffer. it should be
uint32 compressedSize = CompressedVoiceBuffer.Num();

You need to initialize the buffer large enough depending on your project.

It Works perfect!