rurico / flutter_video_compress

Generate a new file by compressed video, and provide metadata. Get video thumbnail from a video path, supports JPEG/GIF. To reduce app size not using FFmpeg in IOS.
MIT License
185 stars 72 forks source link

[Bug]video compress: ffmpeg isn't supported this platform #88

Closed Muzm closed 1 week ago

Muzm commented 4 years ago

Description

invoke _flutterVideoCompress.compressVideo in android get a error PlatformException(flutter_video_compress, FlutterVideoCompress Error, ffmpeg isn't supported this platform).

Platform

Android

Code Example (if has)

void main() {
// here is my code :
 Future<void> _publish() async {
    final _flutterVideoCompress = FlutterVideoCompress();
    bool res = false;

    await loadingCallback(() async {
      if (video.file != null) {
        final compressed = await _flutterVideoCompress.compressVideo(
          video.file.path,
          quality: VideoQuality.MediumQuality,
        );

        final videoUrl = await CircleService.uploadVideo(
          videoFile: compressed.file,
        );

        if (videoUrl != null) {
          res = await CircleService.uploadVideoStatus(
              videoDescribe: text, videoUrl: videoUrl);
        }
      } else {
        if (images.isNotEmpty) {
          final imageUrls = await CircleService.uploadReportImages(images);

          if (imageUrls != null) {
            res = await CircleService.uploadImageStatus(
                postContent: text, images: imageUrls, location: '');
          }
        } else {
          showToast('请至少添加一张图片');
        }
      }
    }, context: context);

    showToast('发送${res ? '成功' : '失败'}');

    if (res) {
      Navigator.pop(context);
    }
  }
}

Backtracking step (if has)

I had a page it will compress video before upload to server. it will invoke the above function _publish do the compress and upload. everything work fine in ios. but when i run it in android it shows:

I/flutter (20402): FlutterVideoCompress: You can try to subscribe to the 
I/flutter (20402):       compressProgress$ stream to know the compressing state.
D/FFmpeg  (20402): Build.CPU_ABI : x86
D/FFmpeg  (20402): file does not exist, creating it...
E/FFmpeg  (20402): error while opening assets
E/FFmpeg  (20402): java.io.FileNotFoundException: x86/ffmpeg
E/FFmpeg  (20402):  at android.content.res.AssetManager.nativeOpenAsset(Native Method)
E/FFmpeg  (20402):  at android.content.res.AssetManager.open(AssetManager.java:824)
E/FFmpeg  (20402):  at android.content.res.AssetManager.open(AssetManager.java:801)
E/FFmpeg  (20402):  at nl.bravobit.ffmpeg.FFmpeg.isSupported(FFmpeg.java:65)
E/FFmpeg  (20402):  at com.example.flutter_video_compress.FFmpegCommander.compressVideo(FFmpegCommander.kt:25)
E/FFmpeg  (20402):  at com.example.flutter_video_compress.FlutterVideoCompressPlugin.onMethodCall(FlutterVideoCompressPlugin.kt:56)
E/FFmpeg  (20402):  at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:226)
E/FFmpeg  (20402):  at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/FFmpeg  (20402):  at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:631)
E/FFmpeg  (20402):  at android.os.MessageQueue.nativePollOnce(Native Method)
E/FFmpeg  (20402):  at android.os.MessageQueue.next(MessageQueue.java:336)
E/FFmpeg  (20402):  at android.os.Looper.loop(Looper.java:174)
E/FFmpeg  (20402):  at android.app.ActivityThread.main(ActivityThread.java:7356)
E/FFmpeg  (20402):  at java.lang.reflect.Method.invoke(Native Method)
E/FFmpeg  (20402):  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/FFmpeg  (20402):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
I/flutter (20402): FlutterVideoCompress Error: 
I/flutter (20402):       Method: compressVideo
I/flutter (20402):       PlatformException(flutter_video_compress, FlutterVideoCompress Error, ffmpeg isn't supported this platform)
I/flutter (20402): 弹出转圈: NoSuchMethodError: The getter 'length' was called on null.
I/flutter (20402): Receiver: null
I/flutter (20402): Tried calling: length
E/flutter (20402): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Exception: NoSuchMethodError: The getter 'length' was called on null.

Is there any additional config for andoird? or what else i can do to fix the probleam any help is welcome.

Expected solution

i can compress video in android.

edit: flutter info:

[✓] Flutter (Channel stable, v1.17.2, on Mac OS X 10.15.5 19F101, locale
    zh-Hans-CN)
    • Flutter version 1.17.2 at /Users/apple/Downloads/flutter
    • Framework revision 5f21edf8b6 (3 weeks ago), 2020-05-28 12:44:12 -0700
    • Engine revision b851c71829
    • Dart version 2.8.3

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /Users/apple/Library/Android/sdk
    • Platform android-29, build-tools 29.0.3
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.4.1, Build version 11E503a
    • CocoaPods version 1.9.1

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 46.0.2
    • Dart plugin version 193.7361
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6222593)

[!] IntelliJ IDEA Ultimate Edition (version 2020.1.2)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • For information about installing plugins, see
      https://flutter.dev/intellij-setup/#installing-the-plugins

[✓] Connected device (2 available)
    • Android SDK built for x86 • emulator-5554                        •
      android-x86 • Android 10 (API 29) (emulator)
    • iPhone 11 Pro Max         • 8A915208-5928-49A5-BB0C-0EC80770E7DD • ios
      • com.apple.CoreSimulator.SimRuntime.iOS-13-4 (simulator)