Only Audio Applications

Hi!
My plan is to develop a radio simulation platform which uses mediasoup as its SFU.
I am quite new in the topic audio streaming and therefore my question is just stupid:

In most cases, both audio and video are transmitted. Because I don’t need the video codec in my project, I have removed all codecs from the documentation that have to do with audio.
Server:

const mediaCodecs = [
    {
        kind: "audio",
        mimeType: 'audio/opus',
        payloadType: 111,
        clockRate: 48000,
        channels: 2,
    },
]

On the client side I just request the audio stream:

async function getVideoStream() {
    return new Promise((resolve, reject) => {
        navigator.getUserMedia({
            audio: true,
            video: true
        }, (stream) => {
            const track = stream.getVideoTracks()[0]
            resolve({
                stream,
                track
            })
        }, error => {
            reject(error.message)
        })
    })
}

Somehow, however, mediasoup crashes when only an audio track arrives at the server, but when I send video and audio, everything works without a hitch.

Where is the log:

mediasoup:WebRtcTransport connect() +9ms  mediasoup:Channel request() [method:transport.connect, id:3] +9ms
  mediasoup:Channel request succeeded [method:transport.connect, id:3] +0ms
  mediasoup:Transport produce() +55ms
  mediasoup:Channel request() [method:transport.produce, id:4] +47ms
  mediasoup:ERROR:Channel [pid:1130 RTC::Producer::Producer() | throwing MediaSoupTypeError: audio/opus codec not supported for simulcast +0ms
  mediasoup:ERROR:Channel [pid:1130 Worker::OnChannelRequest() | throwing MediaSoupTypeError: audio/opus codec not supported for simulcast [method:transport.produce] +37ms
  mediasoup:WARN:Channel request failed [method:transport.produce, id:4]:  [method:transport.produce] +0ms
/mnt/c/Users/joamb/Documents/GitHub/vHEMS-v2/server/node_modules/mediasoup/node/lib/Channel.js:192
                        sent.reject(new TypeError(msg.reason));
                                    ^

TypeError:  [method:transport.produce]
    at Channel.processMessage (/mnt/c/Users/joamb/Documents/GitHub/vHEMS-v2/server/node_modules/mediasoup/node/lib/Channel.js:192:37)
    at Socket.<anonymous> (/mnt/c/Users/joamb/Documents/GitHub/vHEMS-v2/server/node_modules/mediasoup/node/lib/Channel.js:69:34)
    at Socket.emit (node:events:390:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Socket.Readable.push (node:internal/streams/readable:234:10)
    at Pipe.onStreamRead (node:internal/stream_base_commons:199:23)

Node.js v17.1.0

Obviously things are not as easy as I expected. Maybe someone here has an Idea.
Thanks in advance, Johannes!

What could possibly went wrong? :grinning_face_with_smiling_eyes: You actually request the video stream. And also force more than one encoding in the options passed to transport.produce.

2 Likes

Well… Yes.
For me it was the encodung stuff. When passing only the track to the produce function, things are working fine.
Thank you for your quick answer!

Hello , Even im getting the same error . can u tell which codec should i use , i have used the same as above in your case

He was producing video track instead of audio track, which triggered the issue in his case. Make sure you are producing audio track.

You have have to share that part of code where you produce track along with the options you pass to .produce method. Also you may have to check on your server what media codecs are you passing to worker.createRouter, you may have to share that part of code as well.

I have cloned this repo this is for video and made the changes for audio like in index.js made audio to true and video to false and then got the stream using getAudioTracks[0] these are the changes i made

and then im getting the error of audio/opus not supported , please help me out with this

I was able to reproduce it, actually the issue is because of these encoding parameters. For now you can make it an empty array to make it work in your case. You may have to create js build again to reflect the changes.