Opus Comments not working
Closed this issue · 6 comments
Hi,
first: thanks for VorbisJava!
I think I found a problem with Opus Comments: OpusTags uses VorbisStyleComments, but I always get the error: Framing bit not set, invalid when I try to read them:
java.lang.IllegalArgumentException: Framing bit not set, invalid
at org.gagravarr.vorbis.VorbisStyleComments.(VorbisStyleComments.java:84)
at org.gagravarr.opus.OpusTags.(OpusTags.java:30)
at org.gagravarr.opus.OpusPacketFactory.create(OpusPacketFactory.java:64)
at org.gagravarr.opus.OpusFile.(OpusFile.java:84)
at org.gagravarr.opus.OpusFile.(OpusFile.java:60)
at org.gagravarr.opus.OpusFile.(OpusFile.java:54)
at OpusService.main(OpusService.java:43)
I found this on the Opus site:
https://wiki.xiph.org/OggOpus
- 8 byte 'OpusTags' magic signature (64 bits)
- The remaining data follows the vorbis-comment header design used in OggVorbis (without the "framing-bit"), OggTheora, and Speex:
- Vendor string (always present).
** 4-byte little-endian length field, followed by length bytes of UTF-8 vendor string. - TAG=value metadata strings (zero or more).
** 4-byte little-endian string count.
** Count strings consisting of 4-byte little-endian length and length bytes of UTF-8 string in "tag=value" form.
- Vendor string (always present).
Maybe the framing bit check shouldn't be done in Opus?
I've just tried with the Opus Comments tool, and the test Opus file I have:
$ java -classpath tools/target/vorbis-java-tools-0.7-SNAPSHOT-jar-with-dependencies.jar org.gagravarr.opus.tools.OpusCommentTool -l core/src/test/resources/testOPUS.opus
title=Test Title
artist=Test Artist
comment=Test Comment
encoder=opusenc from opus-tools 0.1.2
No warnings/errors there about framing
Could you test your code with the test file in core/src/test/resources/
? And if that works, could you please share a small test Opus file that you have which triggers the issue?
Just tried with OpusCommentTool, 0.7-SNAPSHOT. I'll try to attach the opus file.
Encoding:
opusenc --comp 10 --framesize 40 --vbr --bitrate 96 --artist test copperhead2.wav copperhead.opus
Encoding using libopus 1.1 (audio)
-----------------------------------------------------
Input: 44.1kHz 2 channels
Output: 2 channels (2 coupled)
40ms packets, 96kbit/sec VBR
Preskip: 356
Encoding complete
-----------------------------------------------------
Encoded: 10.04 seconds
Runtime: 1e-06 seconds
(1.004e+07x realtime)
Wrote: 125820 bytes, 251 packets, 13 pages
Bitrate: 98.8861kbit/s (without overhead)
Instant rates: 80.4kbit/s to 164.6kbit/s
(402 to 823 bytes per packet)
Overhead: 1.37% (container+metadata)
Info:
opusinfo copperhead.opus
Processing file "copperhead.opus"...
New logical stream (#1, serial: 3cbde079): type opus
Encoded with libopus 1.1
User comments section follows...
ENCODER=opusenc from opus-tools 0.1.7
artist=test
ENCODER_OPTIONS=--comp 10 --framesize 40 --vbr --bitrate 96
Opus stream 1:
Pre-skip: 356
Playback gain: 0 dB
Channels: 2
Original sample rate: 44100Hz
Packet duration: 40.0ms (max), 40.0ms (avg), 40.0ms (min)
Page duration: 1000.0ms (max), 912.7ms (avg), 40.0ms (min)
Total data length: 125820 bytes (overhead: 1.37%)
Playback length: 0m:10.000s
Average bitrate: 100.7 kb/s, w/o overhead: 99.28 kb/s
Logical stream 1 ended
OpusCommentTool:
java -classpath ~/git/VorbisJava/tools/target/vorbis-java-tools-0.7-SNAPSHOT-jar-with-dependencies.jar org.gagravarr.opus.tools.OpusCommentTool -l /data/work/temp/copperhead.opus
Exception in thread "main" java.lang.IllegalArgumentException: Framing bit not set, invalid
at org.gagravarr.vorbis.VorbisStyleComments.<init>(VorbisStyleComments.java:76)
at org.gagravarr.opus.OpusTags.<init>(OpusTags.java:30)
at org.gagravarr.opus.OpusPacketFactory.create(OpusPacketFactory.java:64)
at org.gagravarr.opus.OpusFile.<init>(OpusFile.java:84)
at org.gagravarr.opus.OpusFile.<init>(OpusFile.java:60)
at org.gagravarr.opus.OpusFile.<init>(OpusFile.java:54)
at org.gagravarr.opus.tools.OpusCommentTool.main(OpusCommentTool.java:34)
Here is the link to the opus file:
https://drive.google.com/open?id=0BweD-U_mvRqUdG42UWdwVVpYZXM&authuser=0
I commented out the framing bit check, now it works.
(I'm working on augmenting the opus info to include more opus specific info)
I've just tried the same command but with opusenc from libopus 0.9.14 (audio)
on a handful of different files, and all worked fine.
My hunch is that behaviour has changed between libopus 0.9.x and 1.1. I'll try to find a machine with a newer libopus on it, and use that to double check the theory!
Looking into it more, it seems that some of the formats do require a framing bit, and some don't. I've therefore made it an option on a per-format basis, and marked Opus as not using it. With that in place, the tests for the libopus 1.1 files now pass, and OpusCommentTool now works fine on the test 1.1 file