Lakelezz / audiopus

High-level Rust binding of Opus.
ISC License
48 stars 15 forks source link

Request: Please add examples #15

Open saant03 opened 3 years ago

saant03 commented 3 years ago

Hi, thank you for creating this crate. I have been trying to get encoding working with Rust without success. It would be great if there are some examples to get feel for the API. Tx

Lakelezz commented 3 years ago

Hello, I agree, examples should be added. I will look into this for the 0.3-release.

However in the meantime, if you want to use 0.2, I recommend you to take a look at songbird: https://github.com/serenity-rs/songbird/search?p=1&q=audiopus

The 0.3 RC is mostly a different API, you can see the potential differences for songbird in this fork here: https://github.com/adumbidiot/songbird/commit/9fae49ed0cbc8154904a0a2631fa2b3912f2899a due to the problem of https://github.com/serenity-rs/songbird/issues/80.

saant03 commented 3 years ago

Amazing! Thank you

numfin commented 3 years ago

@Lakelezz hi! First of of all thank you for this project! I want to create my own voice chat. I started with reading audio input from my microphone and sending it to my headphones. Now i want to send this audio through internet. I know that skype, teamspeak and discord using opus, but its not a Rust library. So i found rust-rs crate. Encoded my &[f32] to &[u8], got some data, and tried to Decode this data. And.... Opus(BadArgument). The documentantion without examples and only with types was very difficult for me.

Chapter2 (:D sorry)

This time i found your repository (crate). And types in your library are a lot more readable (thank you for awesome project!). But... Always but... I dont understand what opus wants from me. I'm encoding [f32] then trying to decode the same info. Fail. Could you pleeeeease <3 provide an example of full usage? I tried to look at songbird repo, but this repo is too big and difficult to figure out whats going on.

and some pictures so it easier to understand what im trying to do image image

Me (noobie noobie) will be forever thankfull for you :3

zezic commented 2 years ago

It seems like Opus require encoded/decoded audio frame length to match some supported values: https://www.opus-codec.org/docs/html_api/group__opusencoder.html#gace941e4ef26ed844879fde342ffbe546 https://www.opus-codec.org/docs/html_api/group__opusdecoder.html#ga53b7fd5621613c4d7fcc17000ff1c9ec

rumblefrog commented 1 year ago

Hi, are there any examples of Repacketizer? I'm not if the library wrapping is correct on some parts, most notably Repacketizer.

Repacketizer::repacketizer_out_range has an empty return value, whereas opus_repacketizer_out() returns the size of the output packet on success.

I'm also unsure how I'm meant to pass a valid output buffer to repacketizer_out_range either, try_into from a mutable Vec runs into the error of Error::EmptyPacket, does the buffer needs to be pre-populated prior to passing?