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

Wrong sample rate with record_session #1112

Closed
Alienmaster opened this issue Mar 14, 2021 · 16 comments
Closed

Wrong sample rate with record_session #1112

Alienmaster opened this issue Mar 14, 2021 · 16 comments
Labels
bug Something isn't working

Comments

@Alienmaster
Copy link

Alienmaster commented Mar 14, 2021

Describe the bug
When using record_session in my dialplan (or with mod_audio_fork its the same) and set the record_sample_rate to 16khz it works perfect with Chrome 89. When using Firefox 86 (bot x64 on Windows 10) the rate doubles to 32khz. When changing the sample rate to 8khz it works fine with Firefox.

Update: After some testing i can narrow the problem down to the opus codec. When i comment out the mod_opus module the audio data from both browser is fine.

To Reproduce

  1. add the following lines to the dialplan:
<action application="set" data="RECORD_READ_ONLY=true"/>
   <action application="set" data="record_sample_rate=16000"/>
   <action application="record_session" data="/var/freeswitch/meetings/${strftime(%Y-%m-%d-%H-%M-%S)}_${call_uuid}.wav"/>
  1. Join a call with Chrome and record a file. Join a call with Firefox also record a file.
  2. Compare the frequency with eg audacity.

Expected behavior
A record with everytime 16khz sample rate

Package version or git hash

  • Version 1.10.4 in BigBlueButton

I use FreeSwitch in BigBlueButton 2.2.

@Alienmaster Alienmaster added the bug Something isn't working label Mar 14, 2021
@dragos-oancea
Copy link
Contributor

check the SDP . Firefox vs Chrome . The difference may be coming from Opus's fmtp.

@Alienmaster
Copy link
Author

After some testing i was able to narrow it down to the opus codec. I check the SDP.

@Alienmaster
Copy link
Author

Alienmaster commented Mar 15, 2021

When I compare the two Local SDP messages, I notice the following:
Chrome:

a=rtpmap:110 telephone-event/48000

and Firefox:

a=rtpmap:101 telephone-event/8000

@dragos-oancea
Copy link
Contributor

The telephone-event is unrelated. Maybe it has something to do with Firefox setting "stereo=1" .

@Alienmaster
Copy link
Author

Is there a way to force this as "mono"?

@dragos-oancea
Copy link
Contributor

try this patch #1115 . put this in opus cfg: <param name="mono" value="1"/>

@dragos-oancea
Copy link
Contributor

the patch will enforce mono. however, I tried to reproduce what you say about the sample rate with Firefox, but I didn't get the same as you, I get a stereo file at 16 khz with the above settings in dialplan, which is expected.

@Alienmaster
Copy link
Author

Alienmaster commented Mar 16, 2021

The whole snippet is this: (due to my fault with the code formatting github didn't show the first line)

<action application="set" data="RECORD_READ_ONLY=true"/>
   <action application="set" data="record_sample_rate=16000"/>
   <action application="record_session" data="/var/freeswitch/meetings/${strftime(%Y-%m-%d-%H-%M-%S)}_${call_uuid}.wav"/>

I made the changes to mod_opus and got the same results: Chrome is fine and Firefox isn't.

Update: On Android 11 its the same with both browsers

@dragos-oancea
Copy link
Contributor

please show FS debug logs (both browsers)

@Alienmaster
Copy link
Author

freeswitch.log
The first connection is Firefox the second is Chrome

@dragos-oancea
Copy link
Contributor

dragos-oancea commented Mar 26, 2021

Needs fix in core media:

if (!zstr((char *) mmap->rm_fmtp) && switch_stristr("stereo=1", (char *) mmap->rm_fmtp)) {
pmap->channels = 2;
} else {
pmap->channels = 1;
}

@Alienmaster
Copy link
Author

I guess you mean this file: https://github.com/signalwire/freeswitch/blob/master/src/switch_core_media.c#L5776
What do i need to change?

@dragos-oancea
Copy link
Contributor

I pushed a commit that does a change in the code I've shown. You will need to add a param to autoload_configs/switch.conf.xml . <param name="max-audio-channels" value="1"/> . Both params (the one in opus cfg too) must be used.

@Alienmaster
Copy link
Author

Could you please link me the commit? I didn't find it, sorry.

@dragos-oancea
Copy link
Contributor

This branch with the 2 commits: #1115

@dragos-oancea
Copy link
Contributor

the branch was merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants