Android MediaRecorder create 16 bit PCM encoded audio file - android

I need to record and save a user's audio file on Android in 16-bit PCM encoding format as supported by AudioFormat.
However examples online use MediaRecorder. Is it possible to use this to record 16-bit PCM encoded files?

Related

How to get PCM bit depth from MediaCodec decoder output MediaFormat?

I'm decoding an online AAC stream with MediaCodec and trying to play it with AudioTrack. AudioTrack requires an AudioFormat which requires knowing the details of PCM encoding. I was able to get the audio to play correctly by configuring it as ENCODING_PCM_16BIT but is that guaranteed to always be 16-bit PCM encoding? I want to avoid making that assumption.
I would expect MediaCodec.Callback.onOutputFormatChanged to get the encoding information as part of it's MediaFormat parameter, which seems like it should be the case by this https://stackoverflow.com/a/49812393/2399236, but this is all the information I get out of the media format by calling toString() on it:
aac-drc-heavy-compression=1
sample-rate=48000
aac-drc-boost-level=127
aac-drc-output-loudness=-1
mime=audio/raw
channel-count=2
aac-drc-effect-type=3
aac-drc-cut-level=127
aac-encoded-target-level=-1
aac-max-output-channel_count=8
aac-target-ref-level=64
aac-drc-album-mode=0
Should I just assume that it's 16-bit PCM, or is there any way to get that information?
Note: I'm targetting min SDK 28, currently testing in debugger on emulated Pixel 2 API 30.

Can FFmpeg record audio on Android?

Since MediaRecoreder not supports encoding to mp3 format.
Can ffmpeg to record audio directly from Android audio source (how to specify this) or it only encodes one file to other format?
You mean using Android to record audio and save it as mp3?
If so, you can code mp3 using libmp3lame. And this is very useful.
Since Android Record outputs a pcm, liblmp3lame can use pcm as input and then output mp3 data.

I have already encoded byte arrays & i want to create mp4 video. is MediaMuxer is helpful?. can i use MediaMuxer without Mediacodec?

I have live encoded byte stream from which i just need to create .mp4 file. how can I do that?.
I found people are using MediaMuxer API along with MediaCodec but I do
not need to use MediaCodec as I already have encoded frames.
Is it possible with MediaMuxer API only? I do not want to use any library for this.

Stream Audio from the Microphone to an API in AMR_WB format

I need to stream audio from the Microphone to a cloud based API in the AMR_WB format which is not currently supported by AudioRecord in Android.
This format works with MediaRecorder, but that will only save audio to a file.
Is there a way to:
Extend audio formats supported by AudioRecord
Live stream the data from the file MediaRecorder is creating to the cloud
Encode/Transcode in real time from AudioRecord output into a non supported format

is it possible to directly encode raw PCM in to Mp4 format in android

is it possible to directly encode raw PCM in to Mp4 format with aac in android? Without using android Media Recorder i want to achieve this.
is it possible to directly encode raw PCM in to Mp4 format with aac in android?
Mp4 is a container which contains different encoders like aac, m4a, H263, x264. You can not achive this without using android media libraries. You can use AudioRecorder Class to record raw PCM data and using ffmpeg or libfaac you can convert it to AAC.

Categories

Resources