qt mac 解决 info.plist 自定义问题

qt 调用 ffmpeg 录音,遇到了权限问题折腾了挺长时间,记录下一个可用的方法,

在qt 创建的项目根目录创建 Info.plist 文件

xml 复制代码
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>CFBundleDevelopmentRegion</key>
        <string>en</string>
        <key>CFBundleExecutable</key>
        <string>${EXECUTABLE_NAME}</string>
        <key>CFBundleIdentifier</key>
        <string>com.yourcompany.${PRODUCT_NAME:rfc1034identifier}</string>
        <key>CFBundleInfoDictionaryVersion</key>
        <string>6.0</string>
        <key>CFBundleName</key>
        <string>${PRODUCT_NAME}</string>
        <key>CFBundlePackageType</key>
        <string>APPL</string>
        <key>CFBundleShortVersionString</key>
        <string>1.0.0</string>
        <key>CFBundleVersion</key>
        <string>1</string>
        <key>LSMinimumSystemVersion</key>
        <string>${MACOSX_DEPLOYMENT_TARGET}</string>
        <key>NSPrincipalClass</key>
        <string>NSApplication</string>
        <key>NSHighResolutionCapable</key>
        <true/>
        <!-----上面的字段估计没有用 -->
        
        <!-- 权限字段 -->
        <key>NSCameraUsageDescription</key>
        <string>This app needs camera access to capture photos and videos</string>
        <key>NSCameraUseContinuityCameraDeviceType</key>
        <true/>
        <!-- <key>NSCameraUsageDescription</key>
        <string>需要相机权限来拍摄照片</string> -->
        <key>NSMicrophoneUsageDescription</key>
        <string>需要麦克风权限来录制音频</string>
        <key>NSLocationWhenInUseUsageDescription</key>
        <string>需要位置权限来提供定位服务</string>
        <key>NSPhotoLibraryUsageDescription</key>
        <string>需要访问照片库来保存和读取图片</string>
    </dict>
</plist>

.pro 文件

.pro 复制代码
QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++17

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
    main.cpp \
    mainwindow.cpp

HEADERS += \
    mainwindow.h

FORMS += \
    mainwindow.ui

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

FFMPEG_HOME = /usr/local/Cellar/ffmpeg/7.1.1_2

INCLUDEPATH += $${FFMPEG_HOME}/include

LIBS += -L $${FFMPEG_HOME}/lib \
           -lavdevice \
           -lavformat \
           -lavcodec \
           -lavutil

# 设置 Info.plist 文件
QMAKE_INFO_PLIST = $$PWD/Info.plist

终于可以正常的拉起麦克风了

相关推荐
简鹿视频3 小时前
视频转mp4格式具体作步骤
ffmpeg·php·音视频·实时音视频
一点晖光11 小时前
centos安装ffmpeg环境
linux·ffmpeg·centos
炒毛豆11 小时前
前端直播开发入门:搞懂推流拉流,掌握播放器核心
ffmpeg
八月的雨季 最後的冰吻1 天前
FFmepg-- 32-ffplay源码- PacketQueue 的线程安全机制 以及 serial 字段的作用
安全·ffmpeg
凯新生物1 天前
mPEG-SS-PLGA-DTX:智能药物递送系统
eureka·flink·ffmpeg·etcd
学而知不足~1 天前
字幕转码杂记
ffmpeg
飞睿科技1 天前
ESP Audio Effects音频库迎来专业升级,v1.2.0 新增动态控制核心
人工智能·物联网·ffmpeg·智能家居·语音识别·乐鑫科技·esp
daizhe2 天前
基于JavaCV实现FFmpeg设置视频moov前置以及截取封面图片
ffmpeg·音视频·javacv