Comments (7)
hi @litao09h , thanks for getting in touch. could you please help me make this issue easier to understand by:
- cleaning up the formatting. currently it looks half formatted, half not.
- posting any relevant error messages and data
- explaining what you're trying to do (for example: "I take raw PCM data from file X, which I obtained by doing Y, and I want to store raw Opus packets in file Z")
- explaining what you expected to see (for example: A file Z which, when I pass it back through decoder.Decode creates a PCM file very close to the original file)
- explaining what you saw, instead. (for example: error message MMM).
Because of the size of this example you posted, by the way, I'm going to guess the problem is almost certainly somewhere in your code. There is a lot of sample code in the _test.go files; I strongly recommend having a look at those and trying to adapt them to fit your needs.
If the problem persists, please report back and we'll sort it out.
Good luck!
(好好儿干啊 😀)
from opus.
Thanks for the quick reply and patient guidance😁
1,Done
2,the code is ok,no error message. using the opus official tool opus_demo to decode the file encoded.opus failed:
➜ aa_opus git:(master) ✗ ~/opus/opus_demo -d 16000 1 encoded.opus test.pcm
libopus 1.2.1
Decoding with 16000 Hz output (1 channels)
Invalid payload length: -1199843657
average bitrate: nan kb/s
maximum bitrate: -0.000 kb/s
bitrate standard deviation: nan kb/s
3, I take raw PCM data from file 1549937764922.pcm, which I obtained from our business (ffplay ok), and I want to store raw Opus packets in file encoded.opus.
4,I expect to decode encoded.opus to pcm with opus_demo and very close to the original file。
from opus.
你好litao 😀
thanks for that. The code seems functional at a glance (although you have a very peculiar error matching pattern at the top :) I would suggest doing: if err = doSomething(); err != nil { .... }
instead). My biggest question right now is around opus_demo, which I have never used as a tool. I found some documentation here: https://chromium.googlesource.com/chromium/deps/opus/+/1.0.1/README which says:
input and output are little-endian signed 16-bit PCM files or opus
bitstreams with simple opus_demo proprietary framing.
(emphasis mine)
Are you sure the opus_demo tool is capable of decoding raw opus data? It seems to me that it would only decode a type of opus stream which it has, itself, encoded. A wrapper around raw opus data which is not Ogg, but something else, entirely.
How do we test this hypothesis?
- create a simple decode.go which takes the file you have created and decodes it to raw PCM (i.e. what you are currently trying to use opus_demo for). The decoder_test.go and opus_test.go files contain a lot of relevant code.
- use this program to decode your .opus file and see what happens. Does it work? then you are almost certain that the .opus data is valid.
- use opus_demo to encode your own raw .pcm file, then pass that file through your new decoder that you created. does it work? if not, it's probably because it's not raw Opus, but a proprietary format
Good luck! 🙂
from opus.
thx.
opus_demo, reference to this project: https://github.com/xiph/opus
opus_demo test files (来一首世上只有妈妈好)
https://raw.githubusercontent.com/litao09h/download/master/opus_test_data.zip
it works fine.
➜ opus git:(defbc370) ✗ ./opus_demo -e audio 16000 1 25600 1549937764922.pcm 1549937764922.opus
libopus 1.2.1
Encoding 16000 Hz input at 64.000 kb/s in auto bandwidth with 320-sample frames.
average bitrate: 60.219 kb/s
maximum bitrate: 104.000 kb/s
active bitrate: 71.471 kb/s
bitrate standard deviation: 13.161 kb/s
➜ opus git:(defbc370) ✗ ll 1549937764922.pcm 1549937764922.opus
total 352
-rw-r--r--@ 1 litao staff 16573 7 1 18:37 1549937764922.opus
-rw-r--r-- 1 litao staff 158400 7 1 18:37 1549937764922.pcm
➜ opus git:(defbc370)
from opus.
Yes, but what is that .opus file, now? Is it actually raw opus blocks? I suspect that there is custom metadata in there.
Note that Opus is a block encoding and you need a message based stream to store it; you can't just save it as a raw stream because you will lose the block boundaries. This, and the documentation I posted earlier, suggest that the opus_demo tool probably does not store raw opus blocks.
As I said: please write a simple decoder and use that to try and decode that .opus file you created using opus_tool.
from opus.
decode error:panic: opus: corrupted stream.
I kown what you mean , you are right.
I will discuss the solution with other colleagues.
thank you so much 😝
from opus.
👍
from opus.
Related Issues (20)
- transfer pcm to opus HOT 2
- run error HOT 2
- Forward error correction flag in decode (decode_fec flag) HOT 9
- How to find sample rate of a stream? HOT 2
- How can I play opus codec audio by using portaudio? HOT 1
- Opus 1.3 release,would we update to new version? HOT 1
- There is a difference between an opus stream (which is an ogg/opus stream) and raw opus data. .opus files are really .ogg files with opus data, which this package doesn't provide a way to write. It does have a reader for it (Stream type), but no writer yet (never bothered to because I haven't needed it so far, but feel free to submit a PR). HOT 2
- "checkptr: unsafe pointer arithmetic" when using go race detector HOT 1
- How to complie in cross platform? HOT 4
- Inconsistent types in README HOT 1
- encoder: invalid argument HOT 1
- Amplify ogg stream? HOT 2
- Byte slice to int16 slice. HOT 2
- How to destroy en(de)coder state? HOT 2
- Get audio from microphone and encode to ogg HOT 1
- Strange distortion when decoding HOT 6
- implicit declaration of function 'OPUS_GET_IN_DTX' HOT 8
- Set encoder bitrate HOT 5
- Declare constants as actual const
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opus.