PCM / WAVE to AAC Conversion in android - android

My application(android 2.2 and later) needs to convert raw PCM audio recorded at 22kHz to AAC- (22 kHz) format. But the MediaCodec API is only available in android 4.1+ .
Is there any way i can convert pcm to aac in android 2.2 and later ?

FFmpeg for Android is a good way to go. Makefiles are tested only on mentioned targets, it doesn't mean they will not work on Froyo (and I believe they will). It is just that I do not have resources to test every possible build scenario. What I currently support is already too much for my equipment.

Related

Is there any delay time when enconding to ogg vorbis in android?

I've been using oggvorbis libraries (found on google) to convert recordings made with my unity app.
While on the PC the code works fine and convert my recordings in 6 seconds approx, when i run the app on my android tablet the convertion turns to approx 30 seconds.
I haven't found text on any problem similar to mine.
Do you know if that behavior (delay in time)is normal when using that library? o could this be a problem related with my own code?
Thanks for reading.
Sorry, unfortunately encoding to Vorbis is not accelerated on ARM devices.
Use AAC or AC3 encoding instead. Both Android and iOS provide accelerated encoding for those targets (realtime or better).

MPEG-TS, Android and FFMPEG

I am receiving the MPEG-TS (MPEG transport stream) packets with the multiplexed H.264 video and AAC audio streams. I need to be able to show the audio and video on the Android phone. My assumption is that I need:
MPEG-TS de-multiplexer
AAC decoder
H.264 decoder
Synchronize the audio and video playback
Assuming that I am right then (in Android 2.x) MPEG-TS de-multiplexer is not part of the OS and must be ported, both AAC and H.264 decoder are part of the Android OS, but I am not sure if they have interface, which allows passing the data in buffers and if they allow mutual timing synchronization. In the worst case those components must be ported here as well.
Can you give me some advices where to start? I was thinking about the FFMPEG porting. Are there any other ways?
Regards,
STeN
Android 4.x has OpenMAX which can play TS with H264 and AAC. You don't even need to worry about synchronisation of audio and video.
Look at the nativemedia sample in the NDK.
If you want to support previous versions of Android, then ffmpeg might be a good choice, but it the maximum it can give you is just decoded video frames in RGB or any other format and decoded audio in PCM. Then you will have to implement renderer and audio playback yourself. I would recommend reading this tutorial - http://dranger.com/ffmpeg/. It is not android specific but it will give you idea how video play works.
You may refer to the android-ffmpeg project on github.
https://github.com/guardianproject/android-ffmpeg
In Gingerbread ( 2.3 ), actually there is a MPEG TS parser in the stagefright framework that you could use. Also, I believe it is well integrated with H264 and AAC decoders. MPEG TS parser is not advertised anywhere but the support is silently sitting there. I believe they have brought it to support Apple HTTP Live streaming in HC or later version but the code is sitting there in the Gingerbread ( 2.3 ) codebase as well. With a minor modification in the framework, you can playback http live streaming ( which actually sends TS packets). I guess the above information would be helpful for you.
Vibgyor
(DISCLAIMER: I'm personally involved in developing the free and open source program linked below)
A static version of FFMpeg (both library and commandline) is provided by ZShaolin http://dyne.org/software/zshaolin also contains other media conversion tools.
Its use can facilitate scripting experiments without having to compile FFMpeg from scratch.

FFmpeg vs OpenSL-ES

I am working on an music player for android,i want to know which would be better for me?
FFMpeg or OpenSL-ES ? which one is easy to deal with?
Thanks
(old question but since i'm passing by...)
You can't compare both, they don't do the same job :
FFMpeg will decode your stream (example : MP3 file) to output PCM for instance
OpenSL will transmit PCM samples to your audio hardware to output the sound (and apply filters and effects)
Actually, OpenSL with API 14 (Android 4.0) is also able to decode some audio codecs such as MP3.

Which audio format can be recorded and played back by iPhone and Android?

I am designing an app that can record short audio files on iPhone and Android that can be played back on both platforms, as well as hopefully any other smartphone.
Right now I'm using *.caf with the iLBC codec, as I know the iPhone does not encode mp3.
Is there a file format/codec that I should use in this case?
It used to be that there were no common audio encoding formats for Android and iPhone.
iPhone: iPhone audio encoding supported formats
Android: Android supported media formats
But Android 2.3.3 adds support for AMR-WB and AAC: Android Audio Encoder AAC
See Media Framework at Android 2.3.3 API changes
So I believe AAC is your format choice if you want interop between Android and iPhone devices and can handle the Android 2.3.3 limitation.
Otherwise, just pick from the list for widest coverage (AMR-NB on Android) or plan on converting the recorded audio to a suitable format.
A quick check shows that AMR is patented and I assume AAC would have some patent coverage as well. PCM is decodable on iPhone and Android and most cellphones at the expense of larger filesize.
All smartphones can play WAV files (even Android as of 2.2). These are known as "Linear PCM" in iOS and "PCM/WAVE" in Android.
Try modifying the file type in your ios version file to be .wav and you should be able to listen to this audio file on an Android phone, as well as a Windows operating system.
You'll find that mp3 has hardware decoding in all recent iOS devices and most Android mobile phones as well (but not cheap tablets, budget phones, etc).
As explained above by typo.pl, the generally compatible format is AMR or WAVE(PCM), but in practice, we prefer a progressive solution:
produce AAC on iOS and Android 2.3.3+, but fallback to produce AMR (WB)
on Android pre-2.3.3. Both formats are playable on all platforms.
I guess it's a fairly easy solution for better compatibility and audio quality.

Mp3 encoder for android, record audio in mp3 format [duplicate]

I have simplified my question and offered a bounty:
What options are there for compressing raw PCM audio data to a mp3 on a Android device.
My original post:
I'm creating a synthesiser on my Android phone, and I've been generating PCM data to send to the speakers. Now I'm wondering if I can encode this PCM data as a mp3 to save to the sdcard. The MediaRecorder object can encode audio coming from the microphone into various formats, but doesn't allow the encoding from programmatically generated audio data.
So my question is, is there a standard Android API for encoding audio? If not, what pure Java or NDK based solutions are there? And can you recommend any of them?
Failing this I'll just have to save my generated audio as a WAV file, which I can easily do.
Pure Java
Look into Tritonus's clean room implementation of javasound which offers an MP3 encoder plugin here: http://www.tritonus.org/plugins.html
Secondly, I would suggest looking into jzoom's libraries JLayer or JLayerME: http://www.javazoom.net/javalayer/javalayer.html (this may only be decode, not sure)
If those doesn't suit your need you can look at this article from 2000 about adding MP3 capabilities to J2SE (with source): http://www.javaworld.com/javaworld/jw-11-2000/jw-1103-mp3.html
Native route
If you want "native" performance I would look at an FFmpeg or Lame port for Android.
Lame: http://lame.sourceforge.net/
As far as i know you can't do this using only the tools in the SDK. According to the official developer guide there isn't an MP3 encoder in the platform (Android Supported Media Formats), so you have to port an encoder on your own using the NDK, then write some wrapper code to receive the audio samples through JNI.
I'm currently working on porting some audio decoders from the Rockbox project for my own music player, and it can record audio into MP3, so maybe you should try to look into it's source and find the encoder library. Most of the decoders have ARM optimalizations which speeds up things noticable, so i guess some of the encoders have also this addition.
Mp3 encoder is not available in android.you have to compile libav with mp3 lame lib you can find code from
http://libavandroid.wordpress.com

Categories

Resources