Can FFmpeg record audio on Android? - 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.

Related

Android MediaRecorder create 16 bit PCM encoded audio file

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?

assembly container for Android MediaCodec

Is there anything that does the opposite of a MediaExtractor on android?
Take one or multiple streams from MediaCodecs (e.g. 1 video and 1 audio)
and package them in a container format for streaming or writing to files?
Looks like the answer is no.
Mostly because of the underlying API is designed for video streaming and not for video compression.
Writing encoder's output to file you'll get raw h264 file. Which can be played using mplayer or ffplay for example.
Also ffmpeg can be used to mux this raw file into some container. But first of all you need to build ffmpeg for android.

Android AudioRecord and MediaRecorder

I'm developing an audio processing application where I need to record audio, and then process it to obtain features of that recording. However, I want the audio in a playable format to play it after with MediaPlayer.
I've seen that to record audio to process it it's better to use AudioRecord, because I can get the raw audio from there. But then I can't write the data to a file in a playable format (is there any library to do this in android?).
I used this method to record raw data and then write it into a file:
http://andrewbrobinson.com/2011/11/27/capturing-raw-audio-data-in-android/
But when i try to play this file on the device, it is not playable.
Then if I use MediaRecorder I don't know how to decode the data to extract the features. I've been looking at MediaExtractor, but it seams that MediaExtractor doesn't decode the frames.
So.. what's the best way to do this? I imagine that's common in any audio processing application, but I wasn't able to find the way to manage this.
Thanks to your replies.
Using AudioRecord is the right way to go if you need to do any kind of processing. To play it back, you have a couple options. If you're only going to be playing it back in your app, you can use AudioTrack instead of MediaPlayer to play raw PCM streams.
If you want it to be playable with other applications, you'll need to convert it to something else first. WAV is normally the simplest, since you just need to add the header. You can also find libraries for converting to other formats, like JOrbis for OGG, or JLayer for MP3, etc.
For best quality result you have to use AudioRecord class instead of MediaRecorder.
Please have a look to below link:
Need a simple example for audio recording
Also have a look to this link: http://i-liger.com/article/android-wav-audio-recording
If you use AudioRecord object to get the raw audio signal, the next step to save it save as a playable file is not so difficult, you just need to add a WAV Head before the audio data you capture, then you get a .WAV file which you can play it on most mobile phones.
A .WAV file is a file under the RIFF format. the RIFF header for WAV file is 44 byte long and contains the sample rate, sample width and channel counts information. you can get the detail information from here
I did the sample function on Android phones and it worked.

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.

encoding pcm samples to mp3 in real time android, possible?

I used LAME to encode wav to mp3 in android succesfuly. now i want to encode it in real time during the caputure of the pcm sample (meaning to pass the buffer insted of the file), is it possible using LAME to do it or i need to write new function for it?
http://lame.sourceforge.net/ - LAME

Categories

Resources