How to read an ogg file in Java without JNI

  1. Import jorbis as a dependenyc of your project
  2. Read the howto : http://www.jcraft.com/jorbis/tutorial/Tutorial.html
  3. Copy the source code. It will work, but will only be able to play a sound (not to convert it)
  4. Look at my JorbisCleanConverter. (https://raw.githubusercontent.com/libetl/soundtransform/master/src/main/java/org/toilelibre/libe/soundtransform/infrastructure/service/audioformat/converter/JorbisCleanConverter.java) and copy everything (you will need to change the catch clauses).
  5. You are now able to transform an ogginputstream into a wav outputstream using a ByteArrayInputStream class. To get the stream entirely, just do .toByteArray(), you can write that in a file and use it as a real wav file.

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *

*