Mp3 Encoding

All your problems with Audio, Video and Images.

Mp3 Encoding

Postby winkle » Tue Jun 15, 2010 8:11 am

Hello.
Has anybody tried to encode audio into mp3 format? I know that android platform only supports mp3 decoding. But I also know a few applications for it that allow mp3 encoding (http://hificorder.com/ for example). I downloaded NDK and tried to compile LAMEmp3. With my poor knowledge of Makefiles, Android.mk files, NDK and C/C++ compiling I can't get any results. Does someone have a solution to mp3 encoding problem?

Thank you.
winkle
Junior Developer
Junior Developer
 
Posts: 10
Joined: Tue Jun 15, 2010 7:54 am

Top

Re: Mp3 Encoding

Postby winkle » Tue Jul 06, 2010 5:18 pm

I've solved this problem few weaks ago.
1) Download latest ndk, cygwin and lamemp3 sources;
1.1) Add ndk path to your PATH variable;
2) Create an Android project in eclipse;
3) Go to project folder and create "jni" directory
4) We need only encoder so copy only "libmp3lame" folder from lame to our new "jni" directory;
4.1) And copy lame.h from %lame_sources%\include to "jni\libmp3lame";
5) At "jni" folder create Androind.mk file and put single line into it:

Code: Select all
include $(call all-subdir-makefiles)


6) Go to "jni\libmp3lame" and create one more Android.mk with follow content:

Code: Select all
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE := mp3lame

LOCAL_SRC_FILES := VbrTag.c \
   bitstream.c \
   encoder.c \
   fft.c \
   gain_analysis.c \
        id3tag.c \
        lame.c \
        newmdct.c \
   presets.c \
   psymodel.c \
   quantize.c \
   quantize_pvt.c \
   reservoir.c \
   set_get.c \
   tables.c \
   takehiro.c \
   util.c \
   vbrquantize.c \
   version.c \
   mpglib_interface.c

LOCAL_LDLIBS := -ldl -lc -lz -lm

include $(BUILD_STATIC_LIBRARY)


7) Go back to "jni" folder and create directory for your jni wrapper. Let's call it "wrapper";
8) Create new Android.mk in "jni\wrapper"

Code: Select all
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE    := wrapper
LOCAL_SRC_FILES := wrapper.c
LOCAL_LDLIBS := -llog
LOCAL_STATIC_LIBRARIES := mp3lame

include $(BUILD_SHARED_LIBRARY)


9) Create wrapper.c in that directory and also copy lame.h;
10) Put in wrapper.c your c code. Look at ndk application examples for help;
11) Open cygwin. Go to your project folder. Tyoe "ndk-build" and press Enter;
12) There would be an error. I haven't got a lot of time, so i just go to sources with errors and comment lines with errors;
13) Try "ndk-build" again. Too many warnings, but it has been compiled!

I hope it'll help to someone. By the way, the encoder is slow.
winkle
Junior Developer
Junior Developer
 
Posts: 10
Joined: Tue Jun 15, 2010 7:54 am

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 20 guests