Flutter:如何使用 ffmpeg 从视频中读取数据

标签 flutter ffmpeg flutter-ffmpeg

我正在尝试使用 lib https://pub.dev/packages/flutter_ffmpeg 从视频中获取元数据,

下面的代码不适用于 ffmpeg

  Directory appDocDir = await getApplicationDocumentsDirectory();
  String appDocPath = appDocDir.path;
  File file = File('{$appDocPath}/folder_name/out.mp4');
  final FlutterFFprobe _flutterFFprobe = new FlutterFFprobe();

 _flutterFFprobe.getMediaInformation(file.path).then((info) => print(info));

我该如何解决上述问题?

最佳答案

首先需要文件存储访问权限,然后 ffmpeg lib 可以访问给定的路径

添加存储权限

permission_handler: ^5.0.1 // in pubspec.yaml file

访问视频前请求运行时权限
    var status = await Permission.storage.status;
          if (status.isUndetermined) {
            // You can request multiple permissions at once.
            Map<Permission, PermissionStatus> statuses = await [
              Permission.storage,
            ].request();
            print(statuses[Permission.storage]); // this must show permission granted. 
          }

最后,将其与具有 之类的存储路径的 ffmpeg 一起使用
          File file = File('/storage/emulated/0/folder_name/out.mp4');
          final FlutterFFprobe _flutterFFprobe = new FlutterFFprobe();

          _flutterFFprobe
              .getMediaInformation(file.path)
              .then((info) => print(info)); // This should print metadata inside of video

关于Flutter:如何使用 ffmpeg 从视频中读取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62373427/

相关文章:

flutter - 未处理的异常:错误状态:调用关闭音频播放器后无法添加新事件

dart - Flutter 中的圆形 CachedNetworkImage

Flutter:ClipRRect 与带有 BoxDecoration 的容器

html - 没有 Content-Length 的流媒体响应

android - ffmpeg 配置时的空过滤器(没有这样的过滤器 'eq' )

FFMPEG NVENC 编码与 Windows10

android - 如何在 flutter 中获取小部件的坐标、比例和旋转数据?

flutter - 如何在没有脚手架的情况下在 Flutter 中使用抽屉?

Flutter:如何使用flutter_ffmpeg为视频添加水印和文字等叠加层?

flutter - ffmpeg 套件 flutter 视频压缩器