Closed JayThadeshwar closed 4 years ago
I think you're using the wrong codec. You're saving a file with .mp3 extension but the codec is AAC: t_CODEC _codec = t_CODEC.CODEC_AAC;
Probably you must use t_CODEC _codec = t_CODEC.CODEC_MP3;
Hope it helps
Looks @robyroad is correct~! Closing for now.
@robyroad @hyochan
I tried changing the codec to t_CODEC _codec = t_CODEC.CODEC_MP3 but yet getting the error. So, I tried printing the stacktrace and got:
I/flutter (31781): FlutterSound.startRecorder (package:flutter_sound/ flutter_sound.dart:247:7)
I/flutter (31781): <asynchronous suspension>
I/flutter (31781): #1 _MyHomePageState.startRecorder (package:call_record/main.dart:88:40)
I/flutter (31781): <asynchronous suspension>
I/flutter (31781): #2 _MyHomePageState.onStartRecorderPressed (package:call_record/main.dart:142:16)
I/flutter (31781): #3 _MyHomePageState.initState.<anonymous closure> (package:call_record/main.dart:55:9)
I/flutter (31781): #4 _rootRunUnary (dart:async/zone.dart:1134:38)
I/flutter (31781): #5 _CustomZone.runUnary (dart:async/zone.dart:1031:19)
I/flutter (31781): #6 _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
I/flutter (31781): #7 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:338:11)
I/flutter (31781): #8 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:265:7)
I/flutter (31781): #9 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:134:11)
I/flutter (31781): #10 _MapStream._handleData (dart:async/stream_pipe.dart:234:10)
I/flutter (31781): #11 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:166:13)
I/flutter (31781): #12 _rootRunUnary (dart:async/zone.dart:1
On line 247 of _fluttersound.dart it throws RecorderRunningException with message Codec not supported. It seems like CODEC_MP3 is not supported. Guide me if I am wrong. As, I checked FlutterSoundPlugin.java where _isAndroidEncoderSupported boolean value returns false for the MP3.
Can you try 3.0.0 also? If I remember correctly mp3 had license issue. @Larpoux
I confirm that neither Android nor iOS may record MP3 because of license issue. (but it is ok for MP3 playback)
One of my(many) plans is to support MP3 recording using lame
(via FFmpeg).
The problem is that actually flutter_sound cannot stream the recording to a specific codec.
Either we will have to encode to MP3 after the end of the recording, but it can delay very much the stopRecorder()
for very large records.
Or we must support low level recording tools on Android or iOS.
This would be very good, because it will also solve #210. But probably much work to do that ...
Note : encoding with a specific Codec after stopRecorder() is actually what I do to record OGG/OPUS on iOS. This is fine for my own use , because my records are very short. But it would be great if it was possible to encode OGG/OPUS or MP3 during the recording.
@hyochan
@Larpoux
@robyroad
So, is there any way I can record call in any other format using flutter_sound
plugin??
Please, elaborate on how can I achieve VOICE_DOWNLINK.
Thank you for all the responses. :100:
Actually, on Android, your choice is very simple 🙄 : the only codec available is AAC. This will be improved very soon, I hope. So actually, if you really want another codec, you must decode and re-encode to the new format. But you cannot do that during recording. You can only do that after the end of the recording.
To record from VOICE_DOWNLINK just specify androidAudioSource: AndroidAudioSource.VOICE_DOWNLINK
as a startRecorder()
parameter. But I do not know if anybody has already tried this option. Perhaps you will be first !
@Larpoux
I tried using androidAudioSource: AndroidAudioSource.VOICE_DOWNLINK
in startRecorder()
but again I got two AAC files which are corrupted(it doesn't contain any data). Also no error or exception was raised, can you explain me what is happening?
Then inorder to check if my code is working properly or not I tried changing androidAudioSource: AndroidAudioSource.VOICE_COMMUNICATION
and it works properly.
So, I think so there is some problem while recording call with VOICE_DOWNLINK
.
@JayThadeshwar ,
This is interesting information. Probably Flutter Sound is actually not compatible with VOICE_DOWNLINK.
I am tagging your issue as Enhancement
requested.
This issue is stale because it has been open 90 days with no activity. Leave a comment or this will be closed in 7 days.
Version of flutter_sound
flutter_sound: ^2.1.1
flutter doctor
Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Linux, locale en_IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3) [!] Android Studio (version 3.5) ✗ Flutter plugin not installed; this adds Flutter specific functionality. ✗ Dart plugin not installed; this adds Dart specific functionality. [✓] VS Code (version 1.41.1) [✓] Connected device (1 available)
Platforms you faced the error (IOS or Android or both?)
Error faced in Android
Expected behavior
When tried to start recording using flutterSound.startRecorder with _AndroidAudioSource.VOICEDOWNLINK expected to start recording and generate mp3 file with recorded sound.
Actual behavior
Didn't started recording and generated two corrupted file.
Tested environment (Emulator? Real Device?)
Redmi Note 4 [Android 7.0]
Steps to reproduce the behavior
Calling startRecorder
main.dart