opus-stream-decoder icon indicating copy to clipboard operation
opus-stream-decoder copied to clipboard

Live Streaming Decoding

Open sberniz opened this issue 5 years ago • 7 comments

Hi, does this have the option for live steram decoding?. I am in need of one. and this is the closest. but not sure if it works. Please let me know, and if you have sample code. thanks

sberniz avatar May 23 '20 18:05 sberniz

If the stream is an Ogg Opus byte stream it should work. I think the internal opusfile lib requires the Ogg header page to be appended first. I haven't tried out-of-sequence Ogg Opus files. Have you seen the Opus example at fetch-stream-audio?

anthumchris avatar May 23 '20 21:05 anthumchris

Hi, thanks, i haven't seen it before..i was reading through the code is a bit confusing.. but to make sure.. it'll work on client side decoding correct?. I'm looking because I have an online radio.i'm using ogg. because is light. and is what i want. but of course. ios does not support it.. and I only have one stream.. i will give it a try tomorrow morning.but if you have any code samples. or hints. let me know. thanks Santiago

On Sat, May 23, 2020 at 2:37 PM AnthumChris [email protected] wrote:

If the stream is an Ogg Opus file it should work. I think the internal opusfile lib requires the Ogg header page to be appended first. I haven't tried out-of-sequence Ogg Opus files. Have you seen the Opus example at fetch-stream-audio https://fetch-stream-audio.anthum.com/?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AnthumChris/opus-stream-decoder/issues/12#issuecomment-633143732, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPLTKU2NFMWPZZN3273TBLRTA6Z5ANCNFSM4NIRVAUQ .

sberniz avatar May 24 '20 02:05 sberniz

Yes, it does client-side decoding. Happy to help, feel free to email me directly and I can make some time.

anthumchris avatar May 24 '20 12:05 anthumchris

Its too slow for streaming, I had to save the decoded frames into a list and play the audio with a delay.

adminy avatar Dec 03 '20 19:12 adminy

@adminy Have you seen the fetch-stream-audio example? You may consider posting a question on StackOverflow if you're encountering difficulties with your code so the community can possibly assist you.

anthumchris avatar Dec 03 '20 21:12 anthumchris

No thanks @AnthumChris, I am sticking with libopus of course, but I don't need programming help. I found out something new from fetch-stream-audio, which is constructing audio buffers ahead of time. The reason I am saying it's slow is because I'm going to be using it in a voice call application, so for me the goal is to reduce latency as much as possible (dropping frames is normal), I think I'm almost there. I'll also be refactoring the code for mono channel sound.

As for the network infrastructure, it will be web sockets since it's a stream not a static file. So again, it is very important that I improve that latency.

adminy avatar Dec 04 '20 00:12 adminy

Nice one! Sounds like a fun project.

anthumchris avatar Dec 04 '20 01:12 anthumchris

@AnthumChris Have you experienced Opus streams stopping on Chrome or Chromium after 2.5 hours?

guest271314 avatar Dec 29 '20 15:12 guest271314

@guest271314 I have not, but it may be best to file a bug with that team. Let's try to keep this thread focused on and specific to the original author's question without potentially digressing from it.

anthumchris avatar Dec 29 '20 15:12 anthumchris

@AnthumChris The Chromium bug was already filed https://bugs.chromium.org/p/chromium/issues/detail?id=1161429. I did not locate your email address and this is the closest open bug in your repository to the issue described.

Yes, live streaming is possible. I have achieved that requirement several ways, with both WAV input and converting WAV to Opus with opusenc and using MediaSource https://github.com/guest271314/captureSystemAudio#stream-file-being-written-at-local-filesystem-to-mediasource-capture-as-mediastream-record-with-mediarecorder-in-real-time and WebTransport for both speech synthesis (essentially the voice use case) and streaming arbitrary live audio to the browser, e.g., https://github.com/guest271314/webtransport/blob/main/webTransportAudioWorkletWebAssemblyMemoryGrow.js. Cheers.

guest271314 avatar Dec 30 '20 16:12 guest271314