RootEncoder
RootEncoder copied to clipboard
AAC Recording Problem
Hello, apologies if this has already been dealt with, but I couldn't find a reference.
We find that in about 50% of cases an audio only .mp4 (aac) file which has been recorded with the library will not playback in certain browsers.
When looking at the file with ffprobe we see this error
[aac @ 0x2217380] Input buffer exhausted before END element found
If we then re-encode with ffmpeg it works fine.
Any ideas gratefully received!
Can you share me an audio that works and other corrupted? Also, let me know in which browsers works and in which is not working (include version and OS to reproduce totally your case).
This could be related to buffer timestamps. Can you reproduce it recording videos? You can record using app examples but remember use the same audio configuration
"This could be related to buffer timestamps. Can you reproduce it recording videos?" This may be the answer. We are using RtspOnlyAudio We also have an audioEffect which under certain conditions replaces the input buffer with pcm data taken from a file (same sample rate as the captured audio) However the problems are happening even when the audio effect is not being used and the input is copied straight to the output.
There are 2 scenarios we are seeing This file sounds ok, but will not load in Chrome on MacOS, it does play back in VLC https://www.dropbox.com/s/7b0c5rxkl503fn3/2.mp4?dl=0
This file is corrupted and will not play back in the browser, but will play in VLC https://www.dropbox.com/s/j37sdoktatdsowj/1.mp4?dl=0
And this is a file recorded using the same code, which is fine. https://www.dropbox.com/s/fb1yxb4e57d4rtw/3.mp4?dl=0
Hello,
This seems a problem with timestamp. The second file sounds like if you cut the end of each buffer
Are you using the same device to record files? If not, please get info about devices working and devices with problems (OS and model). Also, try disable totally audio effect because if it is enabled on some point. It could break all file and we need to discard it.
In my side I will try record multiple files with all my devices to emulate your case using the same audio parameters (according with ffprobe 44100 samplerate, isStereo false and 64000 bps)
Hello, thanks for your help with this.
We are seeing the behaviour on pretty much every device that we try, however it is not consistent.
The same device can record perfectly, but then on another attempt produce the problem. I mainly test on an S21 and am hearing the problem on some recordings but not others.
I will look for an alternative to the audioProcess as a work around, but we do need to use it in the future.
We are in a position to pay/sponsor to have this issue resolved BTW.
samsung a32 gives the issue consistently
Hello,
I can reproduce this problem using Oneplus 7T. I can reproduce the audio in VLC or video app of Ubuntu but no in browser. I will try find the reason. Also, I noticed that this only happens with audio files. Video files are working fine.
I did a new muxer for OnlyAudioBase that record in .aac format: https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/commit/31301b684e5763b0c7bde1b3d6847e95c3a76401 Test it and let me know if it is working for you. This solved the problem using oneplus 7T. I will investigate too a way to solve the problem using MediaMuxer class but if aac muxer is working the priority is low since record a video is working fine with MediaMuxer.
Brilliant, we will try it today and feedback Will this also solve the problem in the stream, or just the recording?
Hello,
This only fix the recording problem. I didn't know that you had stream problems. For stream problems try use this before prepareAudio:
rtspOnlyAudio.setMicrophoneMode(MicrophoneMode.SYNC);
Also, if you have low delay configured in the server. Sometimes could produce problems with fews audio encoders. I detected this problem only using AWS and YouTube servers using low delay. If it is your case try to use normal delay (in YouTube it is 30s). To discard it you can test using other servers like this (it is only to know if the problem is in server or library side): https://github.com/aler9/rtsp-simple-server
About pay/sponsor. Any quantity is welcome. I will need it to buy devices to test
Sorry, yes I focussed on the recording issue, but I should have said that we are also hearing the same effect on the live stream.
I have added the patch and will make the changes that you have suggested.
We are streaming to Wowza Streaming Engine.
Happy to sponsor this great work, will sort that out tonight!
We have updated to the latest release and I have set the microphone mode as suggested. Running with the patch we did not get a stream or recording to the phone. I may not have implemented that properly thought. One thing I have noticed is that when calling stopRecord() (which we do a few seconds before we stop streaming) I see in the android app log E/MPEG4Writer: Stop() called but track is not started or stopped
When I then stop streaming I see E/AudioEncoder: Encoder crashed, trying to recover it E/MediaCodec: getBufferAndFormat - not executing
We are definitely recording a file, as I can listen to it, this may not be related to the same issue, but it would be good to clear it up.