Giter Club home page Giter Club logo

Comments (9)

chris-rudmin avatar chris-rudmin commented on June 29, 2024

I had the decode audio logic in the lib, but decided to remove it, because:

  • Decoding and playback is outside the scope of a recording lib.
  • Up to date browsers can usually play ogg audio with the audio tag.

You can reference the decoder code here

Alternatively, perhaps there is a way to get the PCM out of an audio tag?

from opus-recorder.

paullewis avatar paullewis commented on June 29, 2024

Makes perfect sense that you removed it :) In my case I can't use the <audio> element or new Audio because I require an offlineAudioContext, which is a bit of a bummer as they don't support MediaElementAudioSourceNodes!

One question from me: the decode function takes packets. How does that map to the ogg file blob? Do I convert over to an arraybuffer and fire it into that function, or do I need to break it up in some way first? Sorry for the noob questions, and thank you again for all your hard work on this.

from opus-recorder.

chris-rudmin avatar chris-rudmin commented on June 29, 2024

To get the packets out of an ogg file, you will need to parse each page, and then parse the segment table to get the packet boundaries. I've seen some libs around which can do this. I think speex.js has something and perhaps aurora.js as well.

https://github.com/jpemartins/speex.js/blob/master/src/ogg.js
https://github.com/audiocogs/ogg.js/releases

from opus-recorder.

chris-rudmin avatar chris-rudmin commented on June 29, 2024

If you can follow the logic after encode(), you need to do the same, but backwards.

from opus-recorder.

chris-rudmin avatar chris-rudmin commented on June 29, 2024

I have created a new branch for opus only operation. I have included a decoder for completeness. It has not been documented or thoroughly tested, but the happy path is working. Check it out if you are still in need.

from opus-recorder.

chris-rudmin avatar chris-rudmin commented on June 29, 2024

Merged decoder which allows decoding back to buffers.

from opus-recorder.

paullewis avatar paullewis commented on June 29, 2024

Oh boy, I'm only just catching up on this. It's super that you broke them out to two separate scripts - thank you!

from opus-recorder.

jlev avatar jlev commented on June 29, 2024

@chris-rudmin Any chance you could write a little documentation on how to use the decoding script? I'm trying to use your excellent library to record audio for Twilio, which only accepts mp3, wav, aiff or ulaw, but unfortunately not ogg/opus. So I can either store the files as ogg on the server and transcode with ffmpeg before sending to Twilio, or get access to the buffers after downsampling and save them as wav.

from opus-recorder.

chris-rudmin avatar chris-rudmin commented on June 29, 2024

You create a worker with the decoder and then pass it a typed array with your encoded data along with the decode command. Sounds like it might be easier to use the original recorder is and record wav.
I will add some documentation when I get some time.

from opus-recorder.

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.