In the search local video section of Android local video player development, we can search for a local video and display the image, title, and duration of each video, of course, if you need to add other methods such as the Video length and width, you can use the method in the Video class. Since we have obtained the Video, the next step is to decode the Video. I use ffmpeg to decode the Video, so this is the FFmpeg library that can be used to compile mobile phones using NDK.
[Plain] NDK =/opt/android-ndk-r8d
PLATFORM = $ NDK/platforms/android-8/arch-arm/
PREBUILT = $ NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86
LOCAL_ARM_NEON = true
CPU = armv7-a
OPTIMIZE_CFLAGS = "-mfloat-abi = softfp-mfpu = neon-marm-mcpu = cortex-a8"
PREFIX =./android/$ CPU
./Configure -- target-OS = linux \
-- Prefix = $ PREFIX \
-- Enable-cross-compile \
-- Arch = arm \
-- Enable-nonfree \
-- Enable-asm \
-- Cpu = cortex-a8 \
-- Enable-neon \
-- Cc = $ PREBUILT/bin/arm-linux-androideabi-gcc \
-- Cross-prefix = $ PREBUILT/bin/arm-linux-androideabi -\
-- Nm = $ PREBUILT/bin/arm-linux-androideabi-nm \
-- Sysroot = $ PLATFORM \
-- Extra-cflags = "-O3-fpic-DANDROID-DHAVE_SYS_UIO_H = 1 $ OPTIMIZE_CFLAGS "\
-- Disable-shared \
-- Enable-static \
-- Extra-ldflags = "-Wl,-rpath-link = $ PLATFORM/usr/lib-L $ PLATFORM/usr/lib-nostdlib-lc-lm-ldl-llog "\
-- Disable-ffmpeg \
-- Disable-ffplay \
-- Disable-ffprobe \
-- Disable-ffserver \
-- Disable-swscale \
-- Disable-swresample \
-- Enable-avformat \
-- Enable-avcodec \
-- Disable-optimizations \
-- Disable-debug \
-- Disable-doc \
-- Disable-stripping \
-- Enable-pthreads \
-- Disable-yasm \
-- Enable-zlib \
-- Enable-pic \
-- Enable-small
Make clean
Make-j4 install
$ PREBUILT/bin/arm-linux-androideabi-ar d libavcodec/libavcodec. a inverse. o
$ PREBUILT/bin/arm-linux-androideabi-ld-rpath-link = $ PLATFORM/usr/lib-L $ PLATFORM/usr/lib-soname libffmpeg-neon.so-shared-nostdlib-z noexecstack-Bsymbolic -- whole-archive -- no-undefined-o $ PREFIX/libffmpeg-neon.so libavcodec/libavcodec. a libavformat/libavformat. a libavutil/libavutil. a-lc-lm-lz-ldl-llog -- warn-once -- dynamic-linker =/system/bin/linker $ PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3 /libgcc. a
NDK =/opt/android-ndk-r8d
PLATFORM = $ NDK/platforms/android-8/arch-arm/
PREBUILT = $ NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86
LOCAL_ARM_NEON = true
CPU = armv7-a
OPTIMIZE_CFLAGS = "-mfloat-abi = softfp-mfpu = neon-marm-mcpu = cortex-a8"
PREFIX =./android/$ CPU
./Configure -- target-OS = linux \
-- Prefix = $ PREFIX \
-- Enable-cross-compile \
-- Arch = arm \
-- Enable-nonfree \
-- Enable-asm \
-- Cpu = cortex-a8 \
-- Enable-neon \
-- Cc = $ PREBUILT/bin/arm-linux-androideabi-gcc \
-- Cross-prefix = $ PREBUILT/bin/arm-linux-androideabi -\
-- Nm = $ PREBUILT/bin/arm-linux-androideabi-nm \
-- Sysroot = $ PLATFORM \
-- Extra-cflags = "-O3-fpic-DANDROID-DHAVE_SYS_UIO_H = 1 $ OPTIMIZE_CFLAGS "\
-- Disable-shared \
-- Enable-static \
-- Extra-ldflags = "-Wl,-rpath-link = $ PLATFORM/usr/lib-L $ PLATFORM/usr/lib-nostdlib-lc-lm-ldl-llog "\
-- Disable-ffmpeg \
-- Disable-ffplay \
-- Disable-ffprobe \
-- Disable-ffserver \
-- Disable-swscale \
-- Disable-swresample \
-- Enable-avformat \
-- Enable-avcodec \
-- Disable-optimizations \
-- Disable-debug \
-- Disable-doc \
-- Disable-stripping \
-- Enable-pthreads \
-- Disable-yasm \
-- Enable-zlib \
-- Enable-pic \
-- Enable-small
Make clean
Make-j4 install
$ PREBUILT/bin/arm-linux-androideabi-ar d libavcodec/libavcodec. a inverse. o
$ PREBUILT/bin/arm-linux-androideabi-ld-rpath-link = $ PLATFORM/usr/lib-L $ PLATFORM/usr/lib-soname libffmpeg-neon.so-shared-nostdlib-z noexecstack-Bsymbolic -- whole-archive -- no-undefined-o $ PREFIX/libffmpeg-neon.so libavcodec/libavcodec. a libavformat/libavformat. a libavutil/libavutil. a-lc-lm-lz-ldl-llog -- warn-once -- dynamic-linker =/system/bin/linker $ PREBUILT/lib/gcc/arm-linux-androideabi /4.4.3/libgcc. a note that the NDK above should be replaced with your local path. This script is enabled with neon, so it can only run on a mobile phone with neon. If you want to run it on a non-neon mobile phone, you need to remove the neon feature.
Then execute this script to generate a libffmpeg-neon.so
The next video file will be decoded using ffmpeg.