Closed rayliverified closed 7 years ago
Upon further observation, this behavior only occurs sporadically. Weird... Test device: Sony Xperia X Performance.
Source of issue found.
Cause: MediaRecorder is not very good for recording audio. Depending on hardware, there is a variable delay on recording audio. When .start() is called on the MediaRecorder object, the file immediately starts writing with no delay. However, the microphone input is not saved for anywhere between 0 - 1.5 seconds depending on the device. The only solution is to use AudioRecorder which has next to no delay. AudioRecorder is very complex to implement and outputting to AMR in my research requires reencoding.
As it stands, this issue CANNOT be fixed because the MediaRecorder class is flawed. Google refuses to fix this issue: https://issuetracker.google.com/issues/36927248
Attempts to work around this issue include trimming AMR bytes to remove the blank audio. Unfortunately, trimming bytes does not work because AMR is encoded. To my best knowledge trimming audio at the beginning would require decoding AMR and then reencoding it. (hopefully I am wrong and there is another way?)
Leaving this issue open for 1 week to allow for discussion.
Great work!I did not notice that. According to your work, we should not use MediaRecorder to recording AMR like this way. Seems like that this trick does not work great anymore :)
Maybe we need to find a new solution.
I haven't come across and encoder for AMR. Currently, the only way to record to AMR seems to be with the built in Media Recorder. Also, I do not possess the required knowledge to work with Audio Recorder and hardware audio recording. Gotta leave the library be for the time being!
When recording audio is paused and then resumed, the beginning of the audio upon resuming is cut off. For example, if I record the following bit: "Record Audio Commencing Now (PAUSE) Continue Recording Audio After Pause" It become: "Record Audio Commencing Now --ding Audio After Pause"
There is about 0.8 seconds that is cut off after resuming.