zoukankan      html  css  js  c++  java
  • ffmpeg交叉

    #include <jni.h>
    #include <string>
    #include <unistd.h>
    #include <android/native_window_jni.h>
    
    
    
    extern "C" {
       // #include "libavutil/avutil.h"
        #include <libavcodec/avcodec.h>
    
    }
    
    char StrLine[1024]={0};
    extern "C" JNIEXPORT jstring JNICALL
    Java_com_example_testnativecpp_MainActivity_stringFromJNI(
            JNIEnv* env,
            jobject /* this */) {
        std::string hello = "Hello from C++";
       //av_version_info(
       // return env->NewStringUTF(StrLine);
        return env->NewStringUTF(av_version_info());
    }
    cmake_minimum_required(VERSION 3.4.1)
    
    
    
    #include_directories()
    
    #看来这个Set还是有用的
    set(DIR ../../../../libs)
    
    INCLUDE_DIRECTORIES(
            E:/andprogram/andpro/NDKPROS/TestNativeCpp/app/libs/include/
            )
    
    
    add_library( # Sets the name of the library.
                 native-lib
                 SHARED
                 native-lib.cpp )
    set_property(TARGET native-lib PROPERTY IMPORTED_NO_SONAME 1)
    
    find_library( # Sets the name of the path variable.
            log-lib
            log )
    find_library( # Sets the name of the path variable.
            android-lib
            android )
    #
    add_library(avcodec
            SHARED
            IMPORTED)
    set_target_properties(avcodec
            PROPERTIES IMPORTED_LOCATION
            ${DIR}/armv7-a/libavcodec.so)
    
    add_library(avformat
            SHARED
            IMPORTED)
    set_target_properties(avformat
            PROPERTIES IMPORTED_LOCATION
            ${DIR}/armv7-a/libavformat.so)
    
    add_library(avutil
            SHARED
            IMPORTED)
    set_target_properties(avutil
            PROPERTIES IMPORTED_LOCATION
            ${DIR}/armv7-a/libavutil.so)
    
    add_library(postproc
            SHARED
            IMPORTED)
    set_target_properties(postproc
            PROPERTIES IMPORTED_LOCATION
            ${DIR}/armv7-a/libpostproc.so)
    
    add_library(swresample
            SHARED
            IMPORTED)
    set_target_properties(swresample
            PROPERTIES IMPORTED_LOCATION
            ${DIR}/armv7-a/libswresample.so)
    
    add_library(swscale
            SHARED
            IMPORTED)
    set_target_properties(swscale
            PROPERTIES IMPORTED_LOCATION
            ${DIR}/armv7-a/libswscale.so)
    
    add_library(avfilter
            SHARED
            IMPORTED)
    set_target_properties(avfilter
            PROPERTIES IMPORTED_LOCATION
            ${DIR}/armv7-a/libavfilter.so)
    
    #
    
    target_link_libraries( # Specifies the target library.
                           native-lib
                           avfilter
                           avcodec
                           avformat
                           avutil
                           postproc
                           swresample
                           swscale
                           ${log-lib}   ${android-lib})


    #!/bin/bash
    NDK=/home/wang/program/android-ndk-r19c
    #ADDI_LDFLAGS="-fPIE -pie"
    #ADDI_CFLAGS="-fPIE -pie -march=armv7-a -mfloat-abi=softfp -mfpu=neon"
    #CPU=armv7-a
    #ARCH=arm
    #CPU=x86
    ARCH=x86
    #HOST=arm-linux
    SYSROOT=$NDK/toolchains/llvm/prebuilt/linux-x86_64/sysroot
    TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin
    PREFIX=$(pwd)/android/$ARCH

    configure()
    {
        ./configure
        --prefix=$PREFIX
        --toolchain=clang-usan
        --enable-cross-compile
        --target-os=android
        --arch=$ARCH
        --sysroot=$SYSROOT
        #--cc=$TOOLCHAIN/armv7a-linux-androideabi21-clang
        #--cxx=$TOOLCHAIN/armv7a-linux-androideabi21-clang++
         --cc =$TOOLCHAIN/i686-linux-android21-clang
        --cxx=$TOOLCHAIN/i686-linux-android21-clang++ 
     #   --strip=$TOOLCHAIN/arm-linux-androideabi-strip
       --strip=$TOOLCHAIN/i686-linux-android-strip
     #   --extra-cflags="$ADDI_CFLAGS"
     #   --extra-ldflags="$ADDI_LDFLAGS"
        --disable-encoders
        --disable-decoders
        --disable-avdevice
        --disable-static
        --disable-doc
        --disable-ffplay
        --disable-network
        --disable-doc
        --disable-symver
        --disable-ffprobe
        --enable-neon
        --enable-shared
        --enable-gpl
        --enable-pic
        --enable-jni
        --enable-pthreads
        --enable-mediacodec
        --enable-encoder=aac
        --enable-encoder=gif
        --enable-encoder=libopenjpeg
        --enable-encoder=libmp3lame
        --enable-encoder=libwavpack
        --enable-encoder=mpeg4
        --enable-encoder=pcm_s16le
        --enable-encoder=png
        --enable-encoder=mjpeg
        --enable-encoder=srt
        --enable-encoder=subrip
        --enable-encoder=yuv4
        --enable-encoder=text
        --enable-decoder=aac
        --enable-decoder=aac_latm
        --enable-decoder=libopenjpeg
        --enable-decoder=mp3
        --enable-decoder=mpeg4_mediacodec
        --enable-decoder=pcm_s16le
        --enable-decoder=flac
        --enable-decoder=flv
        --enable-decoder=gif
        --enable-decoder=png
        --enable-decoder=srt
        --enable-decoder=xsub
        --enable-decoder=yuv4
        --enable-decoder=vp8_mediacodec
        --enable-decoder=h264_mediacodec
        --enable-decoder=hevc_mediacodec
        --enable-bsf=aac_adtstoasc
        --enable-bsf=h264_mp4toannexb
        --enable-bsf=hevc_mp4toannexb
        --enable-bsf=mpeg4_unpack_bframes

    }

    build()
    {
        configure
        make clean
        make -j4
        make install
    }

    build

  • 相关阅读:
    LeetCode 226. Invert Binary Tree
    LeetCode 221. Maximal Square
    LeetCode 217. Contains Duplicate
    LeetCode 206. Reverse Linked List
    LeetCode 213. House Robber II
    LeetCode 198. House Robber
    LeetCode 188. Best Time to Buy and Sell Stock IV (stock problem)
    LeetCode 171. Excel Sheet Column Number
    LeetCode 169. Majority Element
    运维工程师常见面试题
  • 原文地址:https://www.cnblogs.com/cnchengv/p/15182856.html
Copyright © 2011-2022 走看看