ffmpeg-kit icon indicating copy to clipboard operation
ffmpeg-kit copied to clipboard

MissingPluginException(No implementation found for method getLogLevel on channel flutter.arthenica.com/ffmpeg_kit) package:flutter/src/services/platform_channel.dart 332:7 MethodChannel._invokeMethod

Open stephane-archer opened this issue 1 year ago • 9 comments

I added ffmpeg_kit_flutter to my Flutter app but when doing flutter test I get the following message:

  MissingPluginException(No implementation found for method getLogLevel on channel flutter.arthenica.com/ffmpeg_kit)
  package:flutter/src/services/platform_channel.dart 332:7  MethodChannel._invokeMethod

How to solve this?

stephane-archer avatar May 22 '24 13:05 stephane-archer

Hi @stephane-archer were you able to find a solution to this?

kkuivi avatar May 25 '24 03:05 kkuivi

Hi @kkuivi, no I didn't find a solution

stephane-archer avatar May 27 '24 09:05 stephane-archer

I am getting the error if I run it in a Background service or another isolate; When I run it in my main Isolate it works fine T_T

RudyTM avatar May 28 '24 19:05 RudyTM

Hi @RudyTM were you able to find a solution to this?

duggisetty avatar May 29 '24 13:05 duggisetty

Sadly no @duggisetty

I am using flutter 3.19.6 The package what I am using for this, is flutter_background_service I have tried using FlutterIsolate; I have used DartPluginRegistrant.ensureInitialized() in my service too. I also tried t oregister the plugins at app level instead of Activity :|

But no, no success I'll try today, if I can come with something new.

It's the isolate, In the main isolate it works like a charm.

RudyTM avatar May 29 '24 16:05 RudyTM

Hi @RudyTM do you mind sharing a code snippet of what you are doing in main isolate to make it work?

kkuivi avatar May 29 '24 17:05 kkuivi

Right now I'm using this

@pragma('vm:entry-point')
Future<String?> compressVideo(Map<String, dynamic> json) async {
  final config = VideoCompressionConfig.fromJson(json);
  List<String> commandParts = ["-i", config.inputPath, "-vcodec", "libx264"];

  if (config.crf != null) {
    commandParts.addAll(["-crf", config.getCRF().toString()]);
  }
  if (config.preset != null) {
    commandParts.addAll(["-preset", config.getPreset()]);
  }
  if (config.bitrate != null) {
    commandParts.addAll([
      "-b:v",
      "${config.bitrate}k",
      "-maxrate",
      "${config.bitrate}k",
      "-bufsize",
      "${config.bitrate! * 2}k"
    ]);
  }

  commandParts.add(config.outputPath);

  final String command = commandParts.join(" ");
  final session = await FFmpegKit.execute(command);
  final returnCode = await session.getReturnCode();

  if (ReturnCode.isSuccess(returnCode)) {
    return config.outputPath;
  } else {
    final log = await session.getOutput();
    Fimber.e("FFmpeg process failed with log: $log");
    return null;
  }
}

I use it normal :P right now is a top level function because the service, but being a class function it works too...

My config class is this

@JsonSerializable(explicitToJson: true)
class VideoCompressionConfig {
  final String inputPath;
  final String outputPath;
  final VideoPreset? preset;
  final CRF? crf;
  final int? bitrate;

  VideoCompressionConfig({
    required this.inputPath,
    required this.outputPath,
    this.preset,
    this.crf,
    this.bitrate,
  });

  factory VideoCompressionConfig.fromJson(Map<String, dynamic> json) =>
      _$VideoCompressionConfigFromJson(json);

  Map<String, dynamic> toJson() => _$VideoCompressionConfigToJson(this)..removeWhere((dynamic key, dynamic value) => key == null || value == null);

  @override
  String toString() => toJson().toString();

  String getPreset() {
    switch (preset) {
      case VideoPreset.ultrafast:
        return 'ultrafast';
      case VideoPreset.superFast:
        return 'superfast';
      case VideoPreset.veryFast:
        return 'veryfast';
      case VideoPreset.faster:
        return 'faster';
      case VideoPreset.fast:
        return 'fast';
      case VideoPreset.medium:
        return 'medium';
      case VideoPreset.slow:
        return 'slow';
      case VideoPreset.slower:
        return 'slower';
      case VideoPreset.verySlow:
        return 'veryslow';
      default:
        return 'medium';
    }
  }

  int getCRF() {
    switch (crf) {
      case CRF.low:
        return 18;
      case CRF.medium:
        return 28;
      case CRF.high:
        return 35;
      default:
        return 28;
    }
  }
}

RudyTM avatar May 29 '24 18:05 RudyTM

Hi @RudyTM .If you find the solution , can u please share it

duggisetty avatar May 30 '24 06:05 duggisetty

Hi @RudyTM any luck?

eokdev avatar Jun 15 '24 04:06 eokdev

2 month bump. I've also run into this. It breaks my test suite.

brianp avatar Aug 07 '24 20:08 brianp

Same here. Trying to use it on macOS.

Anthoooooooony avatar Aug 12 '24 14:08 Anthoooooooony

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Oct 12 '24 01:10 github-actions[bot]

This issue was closed because it has been stalled for 7 days with no activity.

github-actions[bot] avatar Oct 19 '24 01:10 github-actions[bot]