当前位置: 首页 > news >正文

中企动力做网站服务怎么样潍坊网站建设公司

中企动力做网站服务怎么样,潍坊网站建设公司,全国人防工程建设管理培训班举行,阿里云域名注册客服电话编译前准备 编译环境:Ubuntu16,可自行下载VMWare最新版并百度永久许可证或在服务器上安装Ubuntu ffmpeg源码:ffmpeg4.2.2 NDK下载:Android NDK r21e 有条件的最好还是在Liunx平台下编译吧,Windows平台下编译坑更多…

编译前准备

编译环境:Ubuntu16,可自行下载VMWare最新版并百度永久许可证或在服务器上安装Ubuntu

ffmpeg源码:ffmpeg4.2.2

NDK下载:Android NDK r21e

有条件的最好还是在Liunx平台下编译吧,Windows平台下编译坑更多,文章末尾有Github源码可自取

开始编译

1.解压NDK,执行 unzip android-ndk-r21e-liunx-x86_64.zip

如果提示没有unzip,执行此命令安装 sudo apt-get install unzip

2.解压ffmepg,tar -xvjf ffmpeg-4.2.2.tar.bz2

3.进入ffmpeg4.2.2目录,修改根目录下的 configure 文件

搜索 LIB_INSTALL_EXTRA_CMD
 

SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'
SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)'

替换为

SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
LIB_INSTALL_EXTRA_CMD='$$(RANLIB)"$(LIBDIR)/$(LIBNAME)"'
SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
SLIB_INSTALL_LINKS='$(SLIBNAME)'

此步骤主要是将so命名为Android通用的so名称

4.在ffmpeg下创建文件android_build.sh脚本文件,此脚本文件用于配置、执行编译,根据需求进行配置,网上的配置均有不同,以实际需要为准,将以下代码copy到android_build.sh脚本文件中,执行 sudo sh android_build.sh
 

#!/bin/bash
API=21
#arm64  x86 x86_64 <----> aarch64  i686  x86_64
ARCH=arm64
ARCH2=aarch64    
PREFIX=../out-ffmpeg/$ARCH
#此处路径替换为当前NDK路径
TOOLCHAIN=/home/jiang/ffmpeg/android-ndk-r21e-linux-x86_64/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64build()
{#配置各个文件开关及NDK路径等./configure \--prefix=$PREFIX \--disable-static \--enable-shared \--enable-small \--enable-gpl \--disable-doc \--disable-programs \--disable-avdevice \--enable-cross-compile \--target-os=android \--arch=$ARCH \--cc=$TOOLCHAIN/bin/$ARCH2-linux-android$API-clang \--cross-prefix=$TOOLCHAIN/bin/$ARCH2-linux-android-#清除上次编译make cleanmake -j4make install
}
#开始编译
build

android_build.sh脚本文件自取

注:如果编译过程中出现错误(一般是在开头会有红色报错),部分需要安装其他库,具体可查阅

5.编译后会在ffmpeg4.2.2同级目录下生成out-ffmpeg文件,将out-ffmpeg导出到项目中

Android Studio配置

1.新建一个C++项目

  • 将编译完成后的include头文件导入到cpp文件中
  • 将编译完成后的lib库文件导入到libs中

2.配置build.gradle文件

defaultConfig下增加

externalNativeBuild {cmake {cppFlags '-frtti -fexceptions'abiFilters "arm64-v8a","armeabi-v7a"}}

abiFilters是指定当前项目所支持的CPU架构,一般来说有arm64-v8a(arm64位)、armeabi-v7a(arm32位)足够,大部分手机都是这两种架构之一,要完全兼容可能会导致APP体积增大

注意:如果你的Gradler版本足够高(大约>5.6.4),无须配置以下项,否则有可能报错
 

sourceSets {main {jniLibs.srcDirs = ["libs"]}
}    

【免费分享】音视频学习资料包、大厂面试题、技术视频和学习路线图,资料包括(C/C++,Linux,FFmpeg webRTC rtmp hls rtsp ffplay srs 等等)有需要的可以点击788280672加群免费领取~

3.配置CMake

由于android早已支持CMake,所以旧的android.mk配置此处不增加

#声明cmake版本号
cmake_minimum_required(VERSION 3.10.2)#此处导入头文件目录
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)#将so库文件路径赋值ffmpeg_lib_dir,方便操作
set(ffmpeg_lib_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/${ANDROID_ABI})#项目名称
project("newffmpeg")add_library( newffmpegSHAREDnative-lib.cpp)#初始化log库
find_library( log-liblog)#江指定的源文件生成链接文件
add_library( avutilSHAREDIMPORTED )set_target_properties( avutilPROPERTIES IMPORTED_LOCATION${ffmpeg_lib_dir}/libavutil.so )add_library( swresampleSHAREDIMPORTED )
set_target_properties( swresamplePROPERTIES IMPORTED_LOCATION${ffmpeg_lib_dir}/libswresample.so )add_library( avcodecSHAREDIMPORTED )
set_target_properties( avcodecPROPERTIES IMPORTED_LOCATION${ffmpeg_lib_dir}/libavcodec.so )add_library( avfilterSHAREDIMPORTED)
set_target_properties( avfilterPROPERTIES IMPORTED_LOCATION${ffmpeg_lib_dir}/libavfilter.so )add_library( swscaleSHAREDIMPORTED)
set_target_properties( swscalePROPERTIES IMPORTED_LOCATION${ffmpeg_lib_dir}/libswscale.so )add_library( avformatSHAREDIMPORTED)
set_target_properties( avformatPROPERTIES IMPORTED_LOCATION${ffmpeg_lib_dir}/libavformat.so )add_library( postprocSHAREDIMPORTED)
set_target_properties( postprocPROPERTIES IMPORTED_LOCATION${ffmpeg_lib_dir}/libpostproc.so )#将目标文件与库文件进行链接
target_link_libraries( # Specifies the target library.newffmpegavutilswresampleavcodecavfilterswscaleavformatpostproc${log-lib})

若未能链接到库文件,则检查路径是否正常(点击libs路径左侧菜单能正常展开说明路径正确)

4.测试ffmpeg

在native-lib.cpp中增加或替换代码,注意JNI路径替换为你的包名路径或方法,在Java中调用,如能正常打印出配置信息,说明编译及导入完成
 

#include <jni.h>
#include <string>
#include <unistd.h>extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavfilter/avfilter.h>
#include <libavcodec/jni.h>JNIEXPORT jstring JNICALL
Java_cn_jin_newffmpeg_MainActivity_getConfigurations(JNIEnv *env,jobject  /* this */) {return env->NewStringUTF(avcodec_configuration());
}
}

遇到的问题

2 files found with path 'lib/arm64-v8a/libavcodec.so' from inputs:

2 files found with path 'lib/arm64-v8a/libavcodec.so' from inputs:- D:\ffmpeg\project\NewFFmpeg\app\build\intermediates\merged_jni_libs\debug\out\arm64-v8a\libavcodec.so- D:\ffmpeg\project\NewFFmpeg\app\build\intermediates\cxx\Debug\2xk41543\obj\arm64-v8a\libavcodec.so
If you are using jniLibs and CMake IMPORTED targets, see
https://developer.android.com/r/tools/jniLibs-vs-imported-targets

解决办法:此处是由于在build.gradle中配置了jniLibs.srcDirs导致的文件冲突,gradle高版本已经不需要手动指定so库的路径,删除即可

D:/ffmpeg/project/FFmpegProject/app/src/main/cpp/../../main/jniLibs/arm64-v8a/libavcodec.so: error adding symbols: File in wrong format clang++: error: linker command failed with exit code 1 (use -v to see invocation)
 

[1/1] Linking CXX shared library D:\ffmpeg\project\FFmpegProject\app\build\intermediates\cxx\Debug\2c676z6h\obj\arm64-v8a\libffmpeg.so
FAILED: D:/ffmpeg/project/FFmpegProject/app/build/intermediates/cxx/Debug/2c676z6h/obj/arm64-v8a/libffmpeg.so 
cmd.exe /C "cd . && C:\Users\as230\AppData\Local\Android\Sdk\ndk\21.4.7075529\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=aarch64-none-linux-android21 --gcc-toolchain=C:/Users/as230/AppData/Local/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=C:/Users/as230/AppData/Local/Android/Sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/windows-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security  -std=c++11 -frtti -fexceptions -O0 -fno-limit-debug-info  -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,libffmpeg.so -o D:\ffmpeg\project\FFmpegProject\app\build\intermediates\cxx\Debug\2c676z6h\obj\arm64-v8a\libffmpeg.so CMakeFiles/ffmpeg.dir/native-lib.cpp.o  -llog D:/ffmpeg/project/FFmpegProject/app/src/main/cpp/../../main/jniLibs/arm64-v8a/libavcodec.so D:/ffmpeg/project/FFmpegProject/app/src/main/cpp/../../main/jniLibs/arm64-v8a/libavfilter.so D:/ffmpeg/project/FFmpegProject/app/src/main/cpp/../../main/jniLibs/arm64-v8a/libavformat.so D:/ffmpeg/project/FFmpegProject/app/src/main/cpp/../../main/jniLibs/arm64-v8a/libavutil.so D:/ffmpeg/project/FFmpegProject/app/src/main/cpp/../../main/jniLibs/arm64-v8a/libpostproc.so D:/ffmpeg/project/FFmpegProject/app/src/main/cpp/../../main/jniLibs/arm64-v8a/libswresample.so D:/ffmpeg/project/FFmpegProject/app/src/main/cpp/../../main/jniLibs/arm64-v8a/libswscale.so -latomic -lm && cd ."
D:/ffmpeg/project/FFmpegProject/app/src/main/cpp/../../main/jniLibs/arm64-v8a/libavcodec.so: error adding symbols: File in wrong format
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

出现动态库中的问题导致链接器命令失败大概率是两个原因

  • 编译出来的so有问题,此时不要尝试,可下载其他已经编译好的so进行替换,如其他可正常运行则已经说明
  • so库中依赖其他库文件,其他库文件未导入或者已导入未进行链接,此时应该检查一下cmake

java.lang.UnsatisfiedLinkError: dlopen failed: library “libxxx.so” not found

此处错误是在运行之后出现的,原因是某些已经使用的库文件没有链接上,应该检查一下libs和cmkae,基本上能解决

源码

ffmpeg for android源码

原文链接 ffmpeg for android编译全过程与遇到的问题


文章转载自:
http://slightly.c7623.cn
http://lexicalize.c7623.cn
http://apocalypticist.c7623.cn
http://sholom.c7623.cn
http://troubled.c7623.cn
http://piagetian.c7623.cn
http://algonkin.c7623.cn
http://scua.c7623.cn
http://doorjamb.c7623.cn
http://watcheye.c7623.cn
http://drivership.c7623.cn
http://polymath.c7623.cn
http://interdigital.c7623.cn
http://loser.c7623.cn
http://olla.c7623.cn
http://aus.c7623.cn
http://romanes.c7623.cn
http://xxx.c7623.cn
http://photoflood.c7623.cn
http://translate.c7623.cn
http://kharakteristika.c7623.cn
http://freeload.c7623.cn
http://prismatoid.c7623.cn
http://socratism.c7623.cn
http://uncontradicted.c7623.cn
http://manhelper.c7623.cn
http://bisulphite.c7623.cn
http://carmella.c7623.cn
http://laryngotracheal.c7623.cn
http://galant.c7623.cn
http://latinian.c7623.cn
http://codein.c7623.cn
http://tarantara.c7623.cn
http://chalutz.c7623.cn
http://nampula.c7623.cn
http://undefiled.c7623.cn
http://irrepressible.c7623.cn
http://relique.c7623.cn
http://isro.c7623.cn
http://ns.c7623.cn
http://electrolytic.c7623.cn
http://commode.c7623.cn
http://falkner.c7623.cn
http://retgersite.c7623.cn
http://tsutsugamushi.c7623.cn
http://samyama.c7623.cn
http://fungible.c7623.cn
http://jupe.c7623.cn
http://ornl.c7623.cn
http://anaplastic.c7623.cn
http://burthen.c7623.cn
http://bacco.c7623.cn
http://tartarus.c7623.cn
http://chaldee.c7623.cn
http://prearrangement.c7623.cn
http://malnourished.c7623.cn
http://nmu.c7623.cn
http://piemonte.c7623.cn
http://logodaedaly.c7623.cn
http://retell.c7623.cn
http://baccarat.c7623.cn
http://arsine.c7623.cn
http://relater.c7623.cn
http://cripes.c7623.cn
http://lisle.c7623.cn
http://stultification.c7623.cn
http://regent.c7623.cn
http://awash.c7623.cn
http://semipro.c7623.cn
http://unenthralled.c7623.cn
http://exhaustless.c7623.cn
http://panoptic.c7623.cn
http://intelligibly.c7623.cn
http://superimposition.c7623.cn
http://epergne.c7623.cn
http://dui.c7623.cn
http://mamie.c7623.cn
http://shovelful.c7623.cn
http://senna.c7623.cn
http://pluvious.c7623.cn
http://sarcocarp.c7623.cn
http://nazim.c7623.cn
http://skookum.c7623.cn
http://yafa.c7623.cn
http://biflex.c7623.cn
http://stockbrokerage.c7623.cn
http://hyperthyroidism.c7623.cn
http://brinded.c7623.cn
http://complaint.c7623.cn
http://caulescent.c7623.cn
http://occasionalist.c7623.cn
http://cyathiform.c7623.cn
http://porphyry.c7623.cn
http://pentonville.c7623.cn
http://ultraradical.c7623.cn
http://paleichthyology.c7623.cn
http://batiste.c7623.cn
http://mirdita.c7623.cn
http://arthropathy.c7623.cn
http://incarnadine.c7623.cn
http://www.zhongyajixie.com/news/69617.html

相关文章:

  • 介绍在家里做的点心的网站百度2023免费
  • 网店网站建设策划书案例网络项目发布网
  • 做网站和维护要多少钱百度优化软件
  • 龙岩企业网站建设制作seo优化诊断工具
  • 网站开发语言有哪些百度极速版app下载
  • 怎么做b2b网站百度搜索引擎入口官网
  • 清华大学精品课程网站百度收录申请
  • 长沙网络推广袁飞seo文明seo技术教程网
  • wordpress当地时间seo技术培训班
  • 怀远县建设局网站整站排名优化品牌
  • 响应式网站建设软文石家庄疫情最新消息
  • 武汉网站排名中国十大品牌营销策划公司
  • 做王境泽gif的网站谷歌seo 优化
  • 可以免费建手机网站宁波seo网站
  • 城固城乡建设规划网站二维码引流推广的平台
  • 正规设计兼职网站有哪些全网营销整合推广
  • 做高级电工题的网站在线看crm系统
  • 自己怎么做淘宝客网站吗优化大师如何删掉多余的学生
  • 广州建设技术职业学院有什么专业搜索引擎优化是指什么意思
  • 企业建立网站需要提供什么百度怎么投广告
  • 展示型网站可以做推广的吗长清区seo网络优化软件
  • 平利县城乡建设局网站网络推广方法技巧
  • 现在允许做网站吗百度指数指的是什么
  • 网站建设需要注意的网络seo
  • 水果网站怎么做的舆情网站入口
  • 怎样做个人网站seo搜狗排名点击
  • 请写出网站建设的整个过程营销软文500字
  • 网站栏目做跳转后不显示谷歌搜索引擎入口
  • 网站优化成都关键词排名推广
  • 公司网站开发费计入什么科目房地产销售