ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

NDK编译FFMPEG库及MeadiaCodec等库出现的各种问题

2021-10-01 13:30:41  阅读:292  来源: 互联网

标签:NDK java FFMPEG License APP armeabi MeadiaCodec android


最近搞新项目,需要在C++层里实现各种音视频逻辑,在网上下载了FFmpeg等库放入Android Studio后,出现各种问题,现在都汇总记录下~

1.外接UVC协议的摄像头时,插上摄像头后,有显示设备列表,但是就没有画面出来。外接摄像头是用了开源库的LibUvcCamera日志也报这样的错:

[506*UVCCamera.cpp:172:connect]:could not open camera:err=-1
E/AndroidRuntime: FATAL EXCEPTION: BaseActivity
Process: com.serenegiant.usbcameratest0, PID: 7753
java.lang.UnsupportedOperationException: open failed:result=-1
at com.serenegiant.usb.UVCCamera.open(UVCCamera.java:204)
at com.serenegiant.usbcameratest0.MainActivity$2$1.run(MainActivity.java:149)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.os.HandlerThread.run(HandlerThread.java:61)

查了很多资料,都说更换NDK版本,但是我试了不行,后来又查了很多资料,在外国一论坛有个大神说toolchain版本有关,然后看了源码编译的Application.mk刚好注释掉了,所以我去掉注释让其生效:

NDK_TOOLCHAIN_VERSION := 4.9

发现没有报错,也能正常显示画面了,下面附上Application.mk修改后的完整代码:

#/*
# * UVCCamera
# * library and sample to access to UVC web camera on non-rooted Android device
# * 
# * Copyright (c) 2014-2017 saki t_saki@serenegiant.com
# * 
# * File name: Application.mk
# * 
# * Licensed under the Apache License, Version 2.0 (the "License");
# * you may not use this file except in compliance with the License.
# *  You may obtain a copy of the License at
# * 
# *     http://www.apache.org/licenses/LICENSE-2.0
# * 
# *  Unless required by applicable law or agreed to in writing, software
# *  distributed under the License is distributed on an "AS IS" BASIS,
# *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# *  See the License for the specific language governing permissions and
# *  limitations under the License.
# * 
# * All files in the folder are under this Apache License, Version 2.0.
# * Files in the jni/libjpeg, jni/libusb, jin/libuvc, jni/rapidjson folder may have a different license, see the respective files.
#*/

# This is just for mips, if you really needs MSA, un-comment and build with GCC.
# Note: Supporting GCC on NDK is already deprecated and GCC will be removed from NDK soon.
NDK_TOOLCHAIN_VERSION := 4.9

APP_PLATFORM := android-14
#APP_ABI := armeabi armeabi-v7a x86 mips
APP_ABI := armeabi-v7a
#APP_OPTIM := debug
APP_OPTIM := release

2.接着ffmpeg和meadiaCodec相关的库:

error: no type named 'shared_ptr' in namespace 'std'

解决办法,在对应文件加入:#include<memory>

error: no type named 'condition_variable' in namespace 'std'

在报错文件加入:#include <condition_variable> 

 error: use of undeclared identifier 'free'

在报错文件头加入:#include <stdlib.h>

最后编译时,因为有很多库相互依赖,会出现这样错误:

More than one file was found with OS independent path 'lib/arm64-v8a/libyuv.so'. If you are using jniLibs and CMake IMPORTED targets

则需在build.gradle加入如下这句:

packagingOptions {
        pickFirst 'lib/arm64-v8a/libffmpeg.so'
        pickFirst 'lib/arm64-v8a/libyuv.so'
        pickFirst 'lib/armeabi-v7a/libyuv.so'
        pickFirst 'lib/armeabi-v7a/libffmpeg.so'
    }

我这里是提示了才加的,没提示的不用加。

packagingOptions放在android目录里即可

标签:NDK,java,FFMPEG,License,APP,armeabi,MeadiaCodec,android
来源: https://blog.csdn.net/toyauko/article/details/115896042

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有