-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
I have opus encoded bytes and I'd like to write them to an opus file; since the only example I found uses an existing opus file to read from then write to a new file, it doesn't fit my need. I don't have a source file, I am taking pcm samples and encoding them with an Opus encoder, so I tried to do this and it didn't work:
OggPacket pkt = new OggPacket((byte[]) outBuf.getData());
OpusAudioData oad = new OpusAudioData(pkt);
opusFile.writeAudioData(oad);
As well as this
OpusAudioData oad = new OpusAudioData((byte[]) outBuf.getData());
opusFile.writeAudioData(oad);
When I tried using the OggPacket, I get this exception:
java.lang.NullPointerException: null
at org.gagravarr.ogg.OggPacket.getGranulePosition(OggPacket.java:74)
at org.gagravarr.ogg.OggStreamAudioVisualData.<init>(OggStreamAudioVisualData.java:28)
at org.gagravarr.ogg.OggStreamAudioData.<init>(OggStreamAudioData.java:21)
at org.gagravarr.opus.OpusAudioData.<init>(OpusAudioData.java:29)
My file creation looks like so:
Path opus = Paths.get("target/test-classes/out.opus");
// clean up existing output files
try {
Files.deleteIfExists(opus);
} catch (IOException e1) {
}
OpusFile opusFile = null;
try {
// set opus out
OpusTags ot = new OpusTags();
OpusInfo oi = new OpusInfo();
oi.setSampleRate(48000);
oi.setNumChannels(2);
//oi.preSkip = 3840
opusFile = new OpusFile(new FileOutputStream(opus.toFile()), oi, ot);
Any examples or clues as to how to accomplish what I need would be greatly appretiated.
Metadata
Metadata
Assignees
Labels
No labels