Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to cross Compile FFMPEG for android support. create <code>jni</code> folder inside your project and put <code>FFMPEG</code> folder inside jni. setup <code>android NDK</code>. </p> <p>Here is a copy of Config.sh which i have used to cross compile ffmpeg for android.</p> <pre><code>Config.sh #!/bin/sh PLATFORM=/home/nishant/Desktop/android/android-ndk-r5b/platforms/android-8/arch-arm PREBUILT=/home/nishant/Desktop/android/android-ndk-r5b/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86 LIBX264=/home/nishant/Desktop/android/workspace/DemoProject/jni/x264 LIB=/home/nishant/Desktop/android/workspace/DemoProject/jni EXTRA_LIBS="-lgcc -lm -ldl -lz -lc" #EXTRA_EXE_LDFLAGS="$PLATFORM/usr/lib/crtbegin_dynamic.o $PLATFORM/usr/lib/crtend_android.o" ./configure --target-os=linux \ --arch=arm \ --enable-version3 \ --enable-gpl \ --enable-nonfree \ --disable-stripping \ --disable-ffmpeg \ --disable-ffplay \ --disable-ffserver \ --disable-ffprobe \ --enable-encoders \ --enable-libfaac \ --disable-muxers \ --disable-devices \ --disable-protocols \ --enable-protocol=file \ --enable-avfilter \ --disable-network \ --disable-mpegaudio-hp \ --disable-avdevice \ --enable-cross-compile \ --cc=$PREBUILT/bin/arm-eabi-gcc \ --nm=$PREBUILT/bin/arm-eabi-nm \ --prefix=/home/nishant/Desktop/android/workspace/DemoProject/jni \ --cross-prefix=$PREBUILT/bin/arm-eabi- \ --enable-postproc \ --extra-libs="$EXTRA_LIBS" \ --extra-cflags="-I$PLATFORM/usr/include/ -I$LIB/include/ -I/home/admin1/x264 -std=gnu99 -fPIC -DANDROID -fpic -mthumb-interwork -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -Wno-psabi -march=armv5te -mtune=xscale -msoft-float -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -DANDROID -Wa,--noexecstack -MMD -MP" \ --disable-asm \ --enable-neon \ --enable-armv5te \ --enable-static \ --disable-shared \ --extra-ldflags="-Wl,-rpath-link=$LIB/lib -L$LIB/lib -nostdlib -Bdynamic -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,nocopyreloc -Wl,-soname,/system/lib/libz.so -Wl,-rpath-link=$PLATFORM/usr/lib,-dynamic-linker=/system/bin/linker -L/usr/lib -L$PLATFORM/usr/lib -nostdlib $PLATFORM/usr/lib/crtbegin_dynamic.o $PLATFORM/usr/lib/crtend_android.o" </code></pre> <p>You can use this Config file to cross compile ffmpeg with some modifications in it.</p> <p>Compile <code>config.sh</code> using the <code>ndk-build</code> command. </p> <p>EDIT :</p> <p>FFMPEG is Bundled with all Audio Encoders and Decoders. For AAC Encoding and Decoding use <code>libfaac</code> and <code>libfaad</code>. You can find Audio Decoding example in <code>libavcodecs</code> <code>api-example.c</code> file. You need to create a <code>JNI Wrapper Class</code> to manipulate the codecs. One of the decoding example from that file i am posting here.</p> <pre><code>static void audio_decode_example(const char *outfilename, const char *filename) { AVCodec *codec; AVCodecContext *c= NULL; int out_size, len; FILE *f, *outfile; uint8_t *outbuf; uint8_t inbuf[AUDIO_INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; AVPacket avpkt; av_init_packet(&amp;avpkt); printf("Audio decoding\n"); /* find the mpeg audio decoder */ codec = avcodec_find_decoder(CODEC_ID_MP2); if (!codec) { fprintf(stderr, "codec not found\n"); exit(1); } c= avcodec_alloc_context(); /* open it */ if (avcodec_open(c, codec) &lt; 0) { fprintf(stderr, "could not open codec\n"); exit(1); } outbuf = malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE); f = fopen(filename, "rb"); if (!f) { fprintf(stderr, "could not open %s\n", filename); exit(1); } outfile = fopen(outfilename, "wb"); if (!outfile) { av_free(c); exit(1); } /* decode until eof */ avpkt.data = inbuf; avpkt.size = fread(inbuf, 1, AUDIO_INBUF_SIZE, f); while (avpkt.size &gt; 0) { out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE; len = avcodec_decode_audio3(c, (short *)outbuf, &amp;out_size, &amp;avpkt); if (len &lt; 0) { fprintf(stderr, "Error while decoding\n"); exit(1); } if (out_size &gt; 0) { /* if a frame has been decoded, output it */ fwrite(outbuf, 1, out_size, outfile); } avpkt.size -= len; avpkt.data += len; if (avpkt.size &lt; AUDIO_REFILL_THRESH) { /* Refill the input buffer, to avoid trying to decode * incomplete frames. Instead of this, one could also use * a parser, or use a proper container format through * libavformat. */ memmove(inbuf, avpkt.data, avpkt.size); avpkt.data = inbuf; len = fread(avpkt.data + avpkt.size, 1, AUDIO_INBUF_SIZE - avpkt.size, f); if (len &gt; 0) avpkt.size += len; } } fclose(outfile); fclose(f); free(outbuf); avcodec_close(c); av_free(c); } </code></pre> <p>Hope it will help you.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload