love2d / love

LÖVE is an awesome 2D game framework for Lua.
https://love2d.org
Other
4.86k stars 390 forks source link

Support for Opus audio codec #1319

Open slime73 opened 7 years ago

slime73 commented 7 years ago

Original report by Muh Muhten (Bitbucket: muhmuhten, GitHub: muhmuhten).


It would be nice to have support for the Opus audio codec.

The big advantage here is that Opus is a pretty good speech codec at moderate bitrates (near-transparency for speech claimed at 24-32kbps), which can save a fair bit of space for voicing.

It also achieves similar quality at substantially lower bitrates vs vorbis &c. for general audio. Some other properties like latency which could plausibly be useful if someone wanted to implement in-game voice chat, I guess.

Some POC integration with OpenAL.

License is identical to Vorbis, so it shouldn't be a problem.

slime73 commented 7 years ago

Original comment by Muh Muhten (Bitbucket: muhmuhten, GitHub: muhmuhten).


0001-Add-Opus-decoder.patch implements an Ogg Opus decoder which accepts the "opus" extension and seems to generally work, at least on single-stream files.

Unfortunately I'm not familiar with the build system or the logistics of dependency management here, so it almost certainly won't build. It requires opusfile and libopus (both Xiph libraries which are probably in your repos) in addition to libogg (which is already required for vorbis).

0002-Just-enough-Xcode-project-mangling-to-build-with-Opu.patch is a horrible hack to make xcode build using libopusfile from /usr/local (e.g. homebrew). Obviously the resulting app isn't portable. Still not sure how to build a framework.

slime73 commented 7 years ago

Original comment by Muh Muhten (Bitbucket: muhmuhten, GitHub: muhmuhten).


slime73 commented 7 years ago

Original comment by Mi 28 (Bitbucket: rcoaxil, ).


I suggest to use this to implement SoundData:encode, as a to-go solution for in-game VoIP.

slime73 commented 7 years ago

Original comment by Sasha Szpakowski (Bitbucket: slime73, GitHub: slime73).


This seems good. I'll merge it in once I test it and add the dependency to cmake / megasource and create a .framework in macOS.

slime73 commented 6 years ago

Original comment by Bart van Strien (Bitbucket: bartbes, GitHub: bartbes).


I've imported this patch in the love-experiments opus-decoder branch, updated it and added opusfile to the linux build system.

slime73 commented 6 years ago

Original comment by Bart van Strien (Bitbucket: bartbes, GitHub: bartbes).


I did some testing and it seems to work fine, but beware of ffmpeg's encoder. I had a (transcoded) file with a negative start timestamp, which opusfile apparently really doesn't like, adding -avoid_negative_ts make_zero got me a file I could play. Given that the official opusfile rejects it, I'm putting the blame on ffmpeg, though.

slime73 commented 5 years ago

Original comment by Miku AuahDark (Bitbucket: AuahDark, GitHub: MikuAuahDark).


I tired to add Opus codec into my custom build of LOVE 11.3 under Windows with some modification and it seems fine. However the changes require some attention especially in Megasource and LOVE CMake script. I can send Pull Request for this if the developers getting interested.

slime73 commented 4 years ago

opus_patches.zip