如何在 firebase 存储中保存 _flutterFFmpeg gif?

How to save a _flutterFFmpeg gif in firebase storage?

编辑: 在@Frank van Puffelen 的帮助下进行一些更改后 我收到一个新错误,请参阅下面更新的代码和更新的错误

大家好,我正在尝试保存我使用 flutter_ffmpeg 创建的 gif:^0.4.2 使用此代码,我试图创建一个从当前 widget.videopathasstring 用户选择的视频的 gif 这是所选视频的路径。

 Directory gifDirectory;
  String gifOutputFile;
  getpreviewvideo() async {
    String currentvideo = widget.videopathasstring;
    await getApplicationDocumentsDirectory().then((directory) {
      print("13");
      gifDirectory = Directory(directory.path + '/gif');
      print("14");
      gifDirectory.exists().then((exists) async {
        print("0");
        if (!exists) {
          print("1");
          await gifDirectory.create();
        }
      }).then((value) => {
            print("3"),
            gifOutputFile = gifDirectory.path +
                '/' +
                DateTime.now().millisecondsSinceEpoch.toString() +
                '.gif',
          });
    });
    print("4");
    var arguments = [
      '-i',
      currentvideo,
      '-t',
      '2.5',
      '-ss',
      '2.0',
      '-f',
      'gif',
      gifOutputFile,
    ];
    _flutterFFmpeg.executeWithArguments(arguments).then((rc) {
      print("FFmpeg process exited with rc $rc");
    });

    return File(gifOutputFile);
  }

问题是我遇到了这个错误

GTMSessionFetcher invoking fetch callbacks, data {length = 0, bytes = 0x}, error (null)
2
GTMSessionFetcher invoking fetch callbacks, data {length = 613, bytes = 0x7b0a2020 226e616d 65223a20 22616c6c ... 36316263 34220a7d }, error (null)
flutter: 13
flutter: 14
flutter: 4
flutter: Invalid argument(s) (path): Must not be null
flutter: 0
-[NSNull length]: unrecognized selector sent to instance 0x1dc5f0558
flutter: 3
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull length]: unrecognized selector sent to instance 0x1dc5f0558'
*** First throw call stack:
(0x181e8904c 0x19a4fdf54 0x181f66014 0x181e1e474 0x181e1d5b0 0x181e15410 0x181e0d0a0 0x100e3c4b8 0x100e3b324 0x100e3bb24 0x10065528c 0x181af9914 0x181afb660 0x181afe788 0x181b0cdd0 0x181b0d5f8 0x1f212a0b8 0x1f2129e94)
libc++abi: terminating with uncaught exception of type NSException
* thread #65, queue = 'com.apple.root.default-qos', stop reason = signal SIGABRT
    frame #0: 0x00000001b8cd0964 libsystem_kernel.dylib`__pthread_kill + 8
libsystem_kernel.dylib`__pthread_kill:
->  0x1b8cd0964 <+8>:  b.lo   0x1b8cd0984               ; <+40>
    0x1b8cd0968 <+12>: pacibsp
    0x1b8cd096c <+16>: stp    x29, x30, [sp, #-0x10]!
    0x1b8cd0970 <+20>: mov    x29, sp
Target 0: (Runner) stopped.
Lost connection to device.
Exited (sigterm)

希望大家帮忙

您似乎没有将文件上传到云存储,这只会在您调用 putFile.

时发生

查看有关 uploading files 的 FlutterFire 文档,了解如何使用 putFile

的示例