当前位置:首页 » 《随便一记》 » 正文

NDK编译FFMPEG库及MeadiaCodec等库出现的各种问题_雪飘碧鸳的博客

1 人参与  2022年02月22日 08:02  分类 : 《随便一记》  评论

点击全文阅读


最近搞新项目,需要在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目录里即可

点击全文阅读


本文链接:http://zhangshiyu.com/post/35117.html

报错  摄像头  文件  
<< 上一篇 下一篇 >>

  • 评论(0)
  • 赞助本站

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

关于我们 | 我要投稿 | 免责申明

Copyright © 2020-2022 ZhangShiYu.com Rights Reserved.豫ICP备2022013469号-1