flutter ffmpeg_kit_flutter 踩坑

LTS区别

pubspec.yaml
LTS可以兼容更低版本的安卓 ios版本,
详情:https://github.com/arthenica/ffmpeg-kit/wiki/LTS-Releases

 ffmpeg_kit_flutter: 5.1.0-LTS
 或者
  ffmpeg_kit_flutter: 5.1.0

备注:安卓 SDK24 表示安卓7
使用非LTS版本可能提示需要修改sdk最低版本
android\app\build.gradle

    defaultConfig {
    
    
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.dict"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        minSdkVersion 20
    }

把最后一行 20改为24就行

路径

官方示例中使用的是相对路径,并不确定在移动端相对路径是相对于哪个路径
测试可以直接使用绝对路径

FFmpegKit.execute('-i /storage/emulated/0/Android/data/com.example.dict/files/95635.spx -y /storage/emulated/0/Android/data/com.example.dict/files/95635.mp3');

打印日志,提示没有解码器

(1)官方把这个插件分为了8个版本
详情:
https://github.com/arthenica/ffmpeg-kit/wiki/Packages
不同的版本带有不同的编解码器.
(2)当使用 “full-gpl” 的时候
pubspec.yaml
改为 注意 “full-gpl” 中的 横线要改为 下划线

ffmpeg_kit_flutter_full_gpl: 5.1.0

引入文件也要修改

import 'package:ffmpeg_kit_flutter_full_gpl/ffmpeg_kit.dart';

具体命令行使用方式 可以搜索ffmpeg 命令行

这个扩展的基本使用 和 pc版的命令行方式基本一致.

猜你喜欢

转载自blog.csdn.net/tangshangkui/article/details/131596220