Coder Social home page Coder Social logo

transfer pcm to raw opus about opus HOT 7 CLOSED

hraban avatar hraban commented on July 1, 2024
transfer pcm to raw opus

from opus.

Comments (7)

hraban avatar hraban commented on July 1, 2024

hi @litao09h , thanks for getting in touch. could you please help me make this issue easier to understand by:

  1. cleaning up the formatting. currently it looks half formatted, half not.
  2. posting any relevant error messages and data
  3. 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")
  4. 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)
  5. 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.

litao09h avatar litao09h commented on July 1, 2024

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.

hraban avatar hraban commented on July 1, 2024

你好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?

  1. 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.
  2. 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.
  3. 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.

litao09h avatar litao09h commented on July 1, 2024

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.

hraban avatar hraban commented on July 1, 2024

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.

litao09h avatar litao09h commented on July 1, 2024

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.

hraban avatar hraban commented on July 1, 2024

👍

from opus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.