question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] bitRate and sampleRate cannot be set on Android

See original GitHub issue

Flutter Sound Version :

  • Released or Beta version ? Released

  • Version number ? flutter_sound: ^6.4.2+1

  • FULL or LITE flavor ? FULL

  • Result of the command “flutter pub deps | grep flutter_sound” (very important) |-- flutter_sound 6.4.2+1 | |-- flutter_sound_platform_interface 6.4.2+1 | |-- flutter_sound_web 6.4.2+1 | | |-- flutter_sound_platform_interface…


Severity

  • Result is not what expected ? The bitRate and sampleRate parameter in startRecorder is not giving correct result. I set bitRate: 48000 and sampleRate: 44100, but the output audio is bitRate: 12800 and sampleRate: 8000

Platforms you faced the error

  • Android 9

  • Real device ? Samsung S8


Logs

(This is very important. Most of the time we cannot do anything if we do not have information on your bug)


Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior: await _flutterSoundRecorder.openAudioSession(); await _flutterSoundRecorder.setSubscriptionDuration(Duration(milliseconds: 500)); await _flutterSoundRecorder.startRecorder( toFile: file.path, bitRate: 48000, sampleRate: 44100, );

Use ffprobe to check the bitrate: ffprobe -v error -show_format -show_streams R_1604830207119.aac Outputs

[STREAM]
index=0
codec_name=amr_nb
codec_long_name=AMR-NB (Adaptive Multi-Rate NarrowBand)
profile=unknown
codec_type=audio
codec_time_base=1/8000
codec_tag_string=samr
codec_tag=0x726d6173
sample_fmt=flt
sample_rate=8000
channels=1
channel_layout=mono
bits_per_sample=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/8000
start_pts=0
start_time=0.000000
duration_ts=41120
duration=5.140000
bit_rate=12800
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=257
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=1
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
TAG:creation_time=2020-11-08T10:10:13.000000Z
TAG:language=eng
TAG:handler_name=SoundHandle
[/STREAM]
[FORMAT]
filename=R_1604830207119.aac
nb_streams=1
nb_programs=0
format_name=mov,mp4,m4a,3gp,3g2,mj2
format_long_name=QuickTime / MOV
start_time=0.000000
duration=5.140000
size=8962
bit_rate=13948
probe_score=100
TAG:major_brand=3gp4
TAG:minor_version=0
TAG:compatible_brands=isom3gp4
TAG:creation_time=2020-11-08T10:10:13.000000Z
TAG:com.android.version=9
[/FORMAT]

Expected behavior A clear and concise description of what you expected to happen.


Additional context**

Add any other context about the problem here.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
tonypottera24commented, Nov 8, 2020

Hi Larpoux,

I didn’t set anything in startRecorder, just use the default codec.

Thanks again for your contribution to this project.

0reactions
Larpouxcommented, Jan 21, 2022

You can try :

myRecorder.StartRecorder( ... , sampleRate: 8000, ...);

If not better maybe it is a problem related with mono/stereo.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setting bit rate and sampling rate-Android - xamarin
I have used mediarecorder native android api for recording. ... The above code doesn't set bit rate and sampling rate to the audio....
Read more >
Sampling audio | Android NDK
Use of a sample rate greater than 48 kHz will typically result in decreased quality because a resampler must be used to play...
Read more >
Android and Audio Formats/Sampling Rates - Software
I have read in a couple of 'internet audio places' that Android takes over all audio streams and up/down converts the sampling rate...
Read more >
48 kHz: How to set it in Android, iOS, macOS and Windows
Click the drop-down and it will show you the sample rate and bit depths options as shown in the photo below: 48 kHz:...
Read more >
Open Camera - Change sample rate for audio - SourceForge
I need to set it to 44100 in order to have sync but there still is no option to change the audio sample...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found