Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null check operator used on a null value #184

Open
HenrikVL opened this issue Jul 15, 2022 · 8 comments
Open

Null check operator used on a null value #184

HenrikVL opened this issue Jul 15, 2022 · 8 comments

Comments

@HenrikVL
Copy link

Unhandled Exception: Null check operator used on a null value

I am encountering an error when trying to compress videos. I am testing the app on an Iphone 12 pro.

I have tried using the following versions of the package:

  • 3.1.1
  • 3.1.0
  • 3.0.0

My system:

  • Computer: Macbook pro m1 13 (Monterey 12.4)
  • Phone for testing: Iphone 12 pro (15.5)
  • IDE: Visual Studio Code
  • Flutter version: 3.0.3

My code:

print("before compression");

final info = await VideoCompress.compressVideo(
  widget.filePath,
  quality: VideoQuality.MediumQuality,
  deleteOrigin: false,
  includeAudio: false,
);

print("after compression");

setState(() {
  compressedInfo = info!.path!; // Dart complains if I don't run a null-check here
  print("info set");
});

Error:

The selected imageFormatGroup is not supported by iOS. Defaulting to brga8888
flutter: before compression
flutter: VideoCompress: You can try to subscribe to the
flutter:       compressProgress$ stream to know the compressing state.
[VERBOSE-2:ui_dart_state.cc(198)] Unhandled Exception: Null check operator used on a null value
#0      new MediaInfo.fromJson (package:video_compress/src/media/media_info.dart:43:21)
#1      Compress.compressVideo (package:video_compress/src/video_compress/video_compressor.dart:154:24)
<asynchronous suspension>
#2      _VideoPageState.build.<anonymous closure> (package:apiir_bikefit/pages/record/video_page.dart:65:28)
<asynchronous suspension>

I first assumed that there was something wrong with the way I was handling the result of the compression (info) or that I had implemented the async await wrong. However, after trying different methods and researching online I can't seem to find the problem.

Additionally, it seems that print("after compression"); is never reached, indicating that there is something wrong with the compression function (though I'm not 100% sure).

Could this be a bug in the package?

@swapnilsinha17
Copy link

swapnilsinha17 commented Jul 16, 2022

@HenrikVL @jonataslaw i also have same issue

File ----/Users/elintminds/Library/Developer/CoreSimulator/Devices/BFEABB05-67D9-4531-A1E9-6760376F5F45/data/Containers/Data/Application/6A224A37-9E94-443A-AB3B-6234DA384DE2/tmp/1 Minute Timer.mp4

flutter: VideoCompress: You can try to subscribe to the flutter: compressProgress$ stream to know the compressing state. [VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: Null check operator used on a null value #0 new MediaInfo.fromJson (package:video_compress/src/media/media_info.dart:43:21) #1 Compress.compressVideo (package:video_compress/src/video_compress/video_compressor.dart:157:24) <asynchronous suspension>

@khamidjon-khamidov
Copy link

khamidjon-khamidov commented Aug 2, 2022

I also have the same issue. I found out that it is happening when I set include_audio to false.

@caleb654
Copy link

Also having this issue. Can confirm what @SomeoneAndNoone said as well.

@eegets
Copy link

eegets commented Sep 28, 2022

video_compress Verison:

  • video_compress: ^3.1.1

My System:

  • MacBook Pro (13-inch, 2020, Four Thunderbolt 3 ports)

Flutter code:

...
  if (Platform.isMacOS) {

      print("MacOs");

      final info = await VideoCompress.getMediaInfo("/Users/wangkai/Downloads/shijiannihao.mkv");
      final thumbnail = await VideoCompress.getFileThumbnail("/Users/wangkai/Downloads/shijiannihao.mkv");  //getFileThumbnail no working
      print("Print: info:$info");
      print("thumbnail: $thumbnail");
    }
...

Log Print:

flutter: MacOs
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Null check operator used on a null value
#0      new MediaInfo.fromJson (package:video_compress/src/media/media_info.dart:43:21)
#1      Compress.getMediaInfo (package:video_compress/src/video_compress/video_compressor.dart:104:22)
<asynchronous suspension>
#2      _MyAppState.getVideoInfo (package:happy_sing/main.dart:51:20)
<asynchronous suspension>

I have two questions

  • 1: There is no callback after the VideoCompress.getFileThumbnail() method is executed
  • 2: VideoCompress.getMediaInfo() returned Null check operator used on a null value error

However, the above two methods can return normally and get the value when executed on an Android phone

@sharadgoregore
Copy link

I also have the same issue. I found out that it is happening when I set include_audio to false.

Thanks man..it worked for me

@JoergPf
Copy link

JoergPf commented Nov 21, 2022

Same here, is there a solution besides setting include_audio to false?

@marinaaraujo97
Copy link

marinaaraujo97 commented Nov 21, 2022

Probably related to #203

@meridorkobi
Copy link

meridorkobi commented Jan 24, 2023

I have the same exception
using ^3.1.2

` static Future<MediaInfo?> compressVideo(File file) async {

MediaInfo? mediainfo;

try {

  await VideoCompress.setLogLevel(0);

  mediainfo = await VideoCompress.compressVideo(file.path,

      quality: VideoQuality.MediumQuality,

      includeAudio: false,

      deleteOrigin: false

  );

  return mediainfo;

} catch (e) {

  VideoCompress.cancelCompression(); //If any error occurs during compression, the process is stopped.

}

return null;

}
`

This is the log-
V/MediaMetadataRetriever( 9817): constructor V/NuMediaExtractor( 9817): NuMediaExtractor constructor E/MediaMetadataRetriever( 9817): setDataSource - FileNotFoundException E/MethodChannel#video_compress( 9817): Failed to handle method call E/MethodChannel#video_compress( 9817): java.lang.IllegalArgumentException E/MethodChannel#video_compress( 9817): at android.media.MediaMetadataRetriever.setDataSource(MediaMetadataRetriever.java:184) E/MethodChannel#video_compress( 9817): at com.otaliastudios.transcoder.source.UriDataSource.applyRetriever(UriDataSource.java:33) E/MethodChannel#video_compress( 9817): at com.otaliastudios.transcoder.source.DefaultDataSource.ensureMetadata(DefaultDataSource.java:41) E/MethodChannel#video_compress( 9817): at com.otaliastudios.transcoder.source.DefaultDataSource.getDurationUs(DefaultDataSource.java:165) E/MethodChannel#video_compress( 9817): at com.otaliastudios.transcoder.source.TrimDataSource.<init>(TrimDataSource.java:31) E/MethodChannel#video_compress( 9817): at com.example.video_compress.VideoCompressPlugin.onMethodCall(VideoCompressPlugin.kt:143) E/MethodChannel#video_compress( 9817): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262) E/MethodChannel#video_compress( 9817): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295) E/MethodChannel#video_compress( 9817): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319) E/MethodChannel#video_compress( 9817): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12) E/MethodChannel#video_compress( 9817): at android.os.Handler.handleCallback(Handler.java:883) E/MethodChannel#video_compress( 9817): at android.os.Handler.dispatchMessage(Handler.java:100) E/MethodChannel#video_compress( 9817): at android.os.Looper.loop(Looper.java:237) E/MethodChannel#video_compress( 9817): at android.app.ActivityThread.main(ActivityThread.java:8167) E/MethodChannel#video_compress( 9817): at java.lang.reflect.Method.invoke(Native Method) E/MethodChannel#video_compress( 9817): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496) E/MethodChannel#video_compress( 9817): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants