AbedElazizShe / light_compressor

A powerful and easy-to-use video compression plugin for Flutter.
MIT License
59 stars 32 forks source link

NullPointerException Error #18

Closed husen-hn closed 2 years ago

husen-hn commented 2 years ago

When I compress the video, I receive a succes message and it also delivers a file output. ذut the output is not usable at all. I saw an error in the log, which is probably the problem.

Log:

E/Compressor( 4661): An error has occurred!
E/Compressor( 4661): java.lang.NullPointerException
E/Compressor( 4661):    at com.abedelazizshe.lightcompressorlibrary.video.Track.<init>(Track.kt:248)
E/Compressor( 4661):    at com.abedelazizshe.lightcompressorlibrary.video.Mp4Movie.addTrack(Mp4Movie.kt:51)
E/Compressor( 4661):    at com.abedelazizshe.lightcompressorlibrary.video.MP4Builder.addTrack(MP4Builder.kt:112)
E/Compressor( 4661):    at com.abedelazizshe.lightcompressorlibrary.compressor.Compressor.processAudio(Compressor.kt:445)
E/Compressor( 4661):    at com.abedelazizshe.lightcompressorlibrary.compressor.Compressor.start(Compressor.kt:404)
E/Compressor( 4661):    at com.abedelazizshe.lightcompressorlibrary.compressor.Compressor.compressVideo(Compressor.kt:160)
E/Compressor( 4661):    at com.abedelazizshe.lightcompressorlibrary.VideoCompressor$startCompression$2.invokeSuspend(VideoCompressor.kt:114)
E/Compressor( 4661):    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
E/Compressor( 4661):    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
E/Compressor( 4661):    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
E/Compressor( 4661):    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
E/Compressor( 4661):    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
E/Compressor( 4661):    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
I/flutter ( 4661): Success

My codes:

final LightCompressor _lightCompressor = LightCompressor();
    final dynamic response = await _lightCompressor.compressVideo(
        path: file.path,
        destinationPath: await _destinationFile,
        videoQuality: VideoQuality.low,
        isMinBitrateCheckEnabled: false,
        frameRate: 24);

    if (response is OnSuccess) {
      print('Success');
    } else if (response is OnFailure) {
      print( response.message.toString());
    } else if (response is OnCancelled) {
      print(response.isCancelled.toString());
    }

Device: Google pixel 3a Android 10

husen-hn commented 2 years ago

flutter clean and then change Gradle version It worked for me