Giter Club home page Giter Club logo

opus's People

Contributors

edaniels avatar egonelbre avatar pionbot avatar sean-der avatar stv0g avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opus's Issues

Is there a plan to support pcm->opus encoding?

Summary

If I understand correctly, pion opus only support decoding operations, is there any plan to support encoding operations in the future?

Motivation

I've written a streaming-WebRTC gateway app that can convert av streams from streaming devices to WebRTC via pion, but now there's a tricky problem, the audio encoding provided by these media devices is usually aac (or can be set to pcm, which is configurable on the device), I can't find a library that implements pcm -> opus in pure go, only some library based on c-go (like this one). The c-go based library has some limitations (e.g. it can't be self-contained), so it would be nice if pion opus supported pcm->opus.

Describe alternatives you've considered

.

Additional context

.

How to decode file encoded by opusenc

There is a file which is encoded by opusenc --raw-rate 16000 nowavheader-stereo.pcm nowavheader-stereo.opus

i can decode it using opusdec --rate 16000 nowavheader-stereo.opus nowavheader-stereo.opus.pcm,

I've tried these code

	opusbs, err := os.ReadFile("./nowavheader-stereo.opus")
	if err != nil {
		panic(err.Error())
	}
	decoder := opus.NewDecoder()
	out := make([]byte, 1920)
	bandwidth, isStereo, err := decoder.Decode(opusbs, out)
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("bandwidth: %+v, isStereo: %+v\n", bandwidth, isStereo)
	_ = decoder

but I got this error
panic: unsupported frame code: 3

file is bellow:
MD5 (nowavheader-stereo.pcm) = 9b5ba9b8bc5b96c8055d93033553184c MD5 (nowavheader-stereo.opus) = 13e606dfa6545c9b51a85a30cef2ab6f

opusenc --version
opusenc opus-tools 0.2 (using libopus 1.5.2) Copyright (C) 2008-2018 Xiph.Org Foundation

how to decode it using this package,any example please?
Archive.zip

Wasm based decode example

In a web worker , this would make it easy to build various apps that need sound

in a server , mobile iot desktop you can do the same with Wazero with no cgo also.

Opus packet parsing

  • Implement/use a bitstream reader
  • Implement/use a reverse bitstream reader
  • Implement the RangeCoder
  • Parse the packet information
  • Parse the opus compressed frame information

Implement CELT

  • Implement the rawbits/reverse bitreader
  • Implement the other symbol reading methods
  • Implement the fixed maths routines (isqrt)
  • ...

Roadmap

This is a covering ticket for the Pion Opus roadmap. If you have any requests feel free to leave them here/vote on others.

0.0.1

  • SILK Decoder
  • CELT Decoder

0.0.2

  • SILK Encoder
  • CELT Encoder

Range Decoder

Extract the ec_ctx from libopus and write tests against it. Write a Go idiomatic version that passes all the same tests

Encode too ?

Question: this is a decoder only ?

no plans to also encode ?

Playback example module contains replace directive

go install github.com/pion/opus/examples/playback@latest

Running this command produces an error message:

go: github.com/pion/opus/examples/playback@latest (in github.com/pion/opus/examples/[email protected]):
	The go.mod file for the module providing named packages contains one or
	more replace directives. It must not contain directives that would cause
	it to be interpreted differently than if it were the main module.

`ParseNextPage()` in oggreader.go does not handle OPUS packets that span multiple segments

Your environment.

  • Version: master

What did you do?

Decoding SILK OGG OPUS streams and some of them are changing from to CELT codec after some time and thus failing.

What did you expect?

Proper decoding of the of the whole SILK encoded stream

What happened?

oggreader returned error that CELT is not supported

Fix

The problem is in the loop that is reading the segments. It does not handle the case if the segment's length is 255, which means that the OPUS packet spans multiple segments

for _, s := range sizeBuffer {

Pseudo code of the correct loop can be found at https://gist.github.com/amishshah/68548e803c3208566e36e55fe1618e1c

Implementing something similar in my own, heavily modified oggreader, solved all the decoding problems.

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.