Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPUS should have two channels in RTSP #63

Open
felipecrs opened this issue Dec 14, 2024 · 16 comments
Open

OPUS should have two channels in RTSP #63

felipecrs opened this issue Dec 14, 2024 · 16 comments

Comments

@felipecrs
Copy link

felipecrs commented Dec 14, 2024

This is causing WebRTC playback not to work in go2rtc.

See AlexxIT/go2rtc#1506 (comment)

@miguelangel-nubla
Copy link

It should also work on mono.
If using only one source (one mic) there is no need to send same data twice, and the whole of the bitrate (instead of half) can be used by the opus codec to encode more detail for that mono channel using the same bandwidth.

The issue is that according to https://datatracker.ietf.org/doc/html/rfc7587#section-7 the rtpmap in the SDP should always be opus/48000/2 (instead of opus/48000/1) regardless of sending one or two channels, and leaving that to the codec.

@felipecrs
Copy link
Author

Got it. That's good.

@felipecrs felipecrs closed this as not planned Won't fix, can't repro, duplicate, stale Dec 14, 2024
@miguelangel-nubla
Copy link

I don't own a Wyzecam, if you want to try it might be as easy as to hardcode the channel number https://github.com/gtxaspec/prudynt-t/blob/76da861f942fad77fff229618c4442892edbc463/src/IMPAudioServerMediaSubsession.cpp#L81C9-L81C29 and make a custom build to check. Else the issue lies in live555.

@felipecrs
Copy link
Author

I am confident it will work, but if go2rtc could make it work instead it would be better.

@gtxaspec
Copy link
Owner

If the spec allows 1 channel, is this a go2rtc problem? This was on my internal roadmap...

@gtxaspec gtxaspec reopened this Dec 14, 2024
@maximko
Copy link

maximko commented Dec 15, 2024

I have same issue with mediamtx. It can't handle sdp with "OPUS/48000" without channel number. See bluenviron/mediamtx#4046

@felipecrs
Copy link
Author

This has been fixed in go2rtc. I think we should close this issue, @gtxaspec.

@gtxaspec gtxaspec closed this as completed Jan 2, 2025
@maximko
Copy link

maximko commented Jan 2, 2025

Why ignoring the spec that clearly says that channel number must be 2? So go2rtc was compliant with spec and prudynt-t was not. Now both are not compliant.

@felipecrs
Copy link
Author

It doesn't seem like prudynt is the only one. Check my latest comment in the go2rtc issue.

@felipecrs
Copy link
Author

Also, we can probably convey it's a good thing that prudynt isn't following this spec. For the sake of data optimization.

@maximko
Copy link

maximko commented Jan 2, 2025

MediaMTX guys refused to do anything with it because they follow the spec and imo it's fair. Spec should be the source of truth otherwise there would be endless incompatibilities. Like Mediamtx and prudynt now.

@felipecrs
Copy link
Author

Got it. Maybe there should be an option in prudynt for this then.

@themactep
Copy link
Collaborator

http://opus-codec.org/ says that opus can handle both mono and stereo. Where is it mandated that it requires two channels?

Here is an excerpt from RFC 6716

2.1.2. Number of Channels (Mono/Stereo) Opus can transmit either mono or stereo frames within a single stream. When decoding a mono frame in a stereo decoder, the left and right channels are identical, and when decoding a stereo frame in a mono decoder, the mono output is the average of the left and right channels. In some cases, it is desirable to encode a stereo input stream in mono (e.g., because the bitrate is too low to encode stereo with sufficient quality). The number of channels encoded can be selected in real-time, but by default the reference encoder attempts to make the best decision possible given the current bitrate.

@maximko
Copy link

maximko commented Jan 2, 2025

Where is it mandated that it requires two channels?

RFC 7587 section 7

@gtxaspec gtxaspec reopened this Jan 2, 2025
@gtxaspec
Copy link
Owner

gtxaspec commented Jan 2, 2025

right,

  o  The media subtype ("opus") goes in SDP "a=rtpmap" as the encoding
      name.  The RTP clock rate in "a=rtpmap" MUST be 48000, and the
      number of channels MUST be 2.

I do remember reading this prior. we should comply with the spec. so thanks to go2rtc for making a fix, we'll need to look into fixing this in prudynt the right way too.

@maximko
Copy link

maximko commented Jan 2, 2025

Also there is no need to actually supply two channels in the feed, just in sdp data so no double audio bandwidth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants