RustAudio / rodio

Rust audio playback library
Apache License 2.0
1.78k stars 232 forks source link

ffmpeg-decoder | A decoder using ffmpeg bindings that can be used as a rodio Source #281

Closed tarkah closed 4 years ago

tarkah commented 4 years ago

https://github.com/tarkah/ffmpeg-decoder-rs

Wanted to post this as an FYI and maybe to see if this should be added to the README eventually. I've created a decoder that uses ffmpeg bindings and implemented the Source trait on it. Works great with a bunch of different audio formats I've thrown at it past what rodio currently supports.

My friend recruited me to help him decode atrac3plus for a rust port of FFIV he is working on. He also wants to use rodio for his project. I started the project thinking I could build a native decoder for atrac3 in Rust, but there is basically no documentation for it. So I decided to leverage ffmpeg since they have working codecs for atrac3. And it supports a lot of formats!

est31 commented 4 years ago

ffmpeg supports a lot of formats indeed (rodio supports a true subset) but the intention of this project is not to become a glorified ffmpeg wrapper, but to do things mainly in Rust. Note that ffmpeg also has a copyleft license which might not be something for everyone. Not sure how to treat ffmpeg in the long term view of the project, as unlike I hoped, the community to write audio decoders in Rust is more nascent than anticipated.

tarkah commented 4 years ago

That makes perfect sense and agreed that pure rust is ideal. Figured I'd throw it out there just in case. I'd love to tackle a native decoder at some point.

Btw, thanks for all the work on rodio. I use it in my rust karaoke player project and it works great!

tarkah commented 4 years ago

I was able to port the atrac3+ decoder I needed from ffmpeg to Rust: https://crates.io/crates/atrac3p-decoder. I haven't looked at much C code before this, so it was definitely a great learning experience. It can use some heavy refactoring to be more Rust idiomatic which should be doable now that my head is around it.

Feel free to close this, thanks!

est31 commented 4 years ago

Really nice! Note that ffmpeg is copyleft licensed so if you ported the code, it counts as derived work and thus you have to license it under copyleft as well. IANAL.

tarkah commented 4 years ago

Ahh, thanks for the heads up, I'll change the license.