abdelaziz-mahdy / flutter_meedu_videoplayer

Cross-Platform Video Player for flutter
https://abdelaziz-mahdy.github.io/flutter_meedu_videoplayer/
MIT License
132 stars 69 forks source link

Error decoding audio #151

Closed Vito0912 closed 10 months ago

Vito0912 commented 11 months ago

I have built a simple app that fetches a stream from a server. Recently, I switched the video type to perform the encoding on the client-side. Since then, I have been receiving an error stating that the audio cannot be decoded ("Error decoding audio."). The error message is displayed in the middle of the screen, which is problematic.

As a temporary solution for my personal project, I would like to suppress or hide the error message. However, in its current state, the plugin is not usable for me.

The exception shown in the console is: PlatformException(, Error decoding audio., null, null)

Note that despite the error message, the audio continues to play, so no error there.

Is there a way to suppress or hide this error message? Any help would be appreciated. Thank you. g1

abdelaziz-mahdy commented 11 months ago

Thank you very much, can you provide the full logs and platform you are using,

And if you are enabling media_kit or not, since it will help me greatly to fix the issue

The logs will help me define the caller of throw of the exception which will help me fix it

Also I think it's coming from the media_kit error stream, so I can disable it, by exposing a flag, but I will have to wait for your logs to be 100% sure

Vito0912 commented 11 months ago

Sorry, I forgot to include the important facts. I just forgot to copy and paste them in. Thank you very much for the fast reply. Here are the other details:

OS: Windows Targeting OS: Windows Flutter: 3.10.6 Plugin Version: 4.2.22

As I am new to using the Flutter cross-platform media player, I am not sure which one is used for Windows. However, since I cannot disable or enable it at initialization, I assume that it is the only option for Windows or not available for Windows.

flutter doctor -v:

    • Flutter version 3.10.6 on channel stable at C:\Framework\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f468f3366c (3 weeks ago), 2023-07-12 15:19:05 -0700
    • Engine revision cdbeda788a
    • Dart version 3.0.6
    • DevTools version 2.23.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[!] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at C:\Users\<>\AppData\Local\Android\sdk
    • Platform android-33-ext4, build-tools 33.0.2
    • Java binary at: C:\Users\<>\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\222.4459.24.2221.9862592\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)
    ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.5.2)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.5.33502.453
    • Windows 10 SDK version 10.0.22000.0

[√] Android Studio (version 2022.1)
    • Android Studio at C:\Users\<>\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\221.6008.13.2211.9619390
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-9505619)

[√] Android Studio (version 2022.2)
    • Android Studio at C:\Users\<>\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\222.4459.24.2221.9862592
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)

[√] IntelliJ IDEA Ultimate Edition (version 2022.3)
    • IntelliJ at C:\Users\<>\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\223.8836.41
    • Flutter plugin version 72.1.4
    • Dart plugin version 223.8888

[√] IntelliJ IDEA Ultimate Edition (version 2023.1)
    • IntelliJ at C:\Users\<>\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\231.8109.175
    • Flutter plugin version 74.0.4
    • Dart plugin version 231.9065

[√] VS Code (version 1.80.2)
    • VS Code at C:\Users\<>\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension can be installed from:
       https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] VS Code (version 1.82.0-insider)
    • VS Code at C:\Users\<>\AppData\Local\Programs\Microsoft VS Code Insiders
    • Flutter extension version 3.71.20230801

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.22621.1992]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 115.0.5790.111
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 115.0.1901.188

[√] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

Flutter logs of normal run:

[flutter_meedu_videoplayer] Fit is BoxFit.fill
[flutter_meedu_videoplayer] Last fit used was contain
[flutter_meedu_videoplayer] Fit is BoxFit.contain
NVIDIA GeForce RTX 2070
media_kit: ANGLESurfaceManager: Direct3D Feature Level: 11_0
1 1
media_kit: VideoOutput: Create Texture: 1565402033424
[log] {"timestamp":"2023-08-05T22:14:20.095897Z","level":"error","prefix":"libmpv_render/dxva2-egl","message":"Failed to create EGL surface"}
media_kit: VideoOutput: Using H/W rendering.
flutter: VideoOutput.Resize
flutter: {handle: 1565223790688, id: 1565402033424, rect: {height: 0, left: 0, top: 0, width: 0}}
flutter: NativeVideoController: Texture ID: 1565402033424
[log] {"timestamp":"2023-08-05T22:14:20.455207Z","level":"error","prefix":"ffmpeg/video","message":"mpeg2video: Invalid frame dimensions 0x0."}
[log] {"timestamp":"2023-08-05T22:14:20.497101Z","level":"error","prefix":"ffmpeg/video","message":"mpeg2video: Invalid frame dimensions 0x0."}
[log] {"timestamp":"2023-08-05T22:14:20.515737Z","level":"error","prefix":"ffmpeg/video","message":"mpeg2video: Invalid frame dimensions 0x0."}
[log] {"timestamp":"2023-08-05T22:14:20.555314Z","level":"error","prefix":"ffmpeg/video","message":"mpeg2video: Invalid frame dimensions 0x0."}
[log] {"timestamp":"2023-08-05T22:14:20.595039Z","level":"error","prefix":"ffmpeg/video","message":"mpeg2video: Invalid frame dimensions 0x0."}
[log] {"timestamp":"2023-08-05T22:14:20.631715Z","level":"error","prefix":"ffmpeg/video","message":"mpeg2video: Invalid frame dimensions 0x0."}
[log] {"timestamp":"2023-08-05T22:14:20.631715Z","level":"error","prefix":"ffmpeg/video","message":"mpeg2video: Invalid frame dimensions 0x0."}
[log] {"timestamp":"2023-08-05T22:14:20.709991Z","level":"error","prefix":"ffmpeg/video","message":"mpeg2video: Invalid frame dimensions 0x0."}
[log] {"timestamp":"2023-08-05T22:14:20.733852Z","level":"error","prefix":"ffmpeg/video","message":"mpeg2video: Invalid frame dimensions 0x0."}
[log] {"timestamp":"2023-08-05T22:14:20.733852Z","level":"error","prefix":"ffmpeg/video","message":"mpeg2video: Invalid frame dimensions 0x0."}
[log] {"timestamp":"2023-08-05T22:14:20.797322Z","level":"error","prefix":"ffmpeg/video","message":"mpeg2video: Invalid frame dimensions 0x0."}
1024 576
media_kit: ANGLESurfaceManager: Direct3D Feature Level: 11_0
media_kit: VideoOutput: Create Texture: 1565409513840
flutter: get
flutter: VideoOutput.Resize
flutter: {handle: 1565223790688, id: 1565409513840, rect: {height: 576, left: 0, top: 0, width: 1024}}
[flutter_meedu_videoplayer] Duration is 0:00:01.320000
[flutter_meedu_videoplayer] media_kit: VideoOutput: Free Texture: 1565402033424
Fit is BoxFit.contain
MediaKitEventLoopHandler::Register: std::thread exit: 1565223790688
MediaKitEventLoopHandler::Dispose: 1565223790688
media_kit: VideoOutput: Free Texture: 1565409513840
VideoOutput::~VideoOutput: 1565223790688

Please note that [log] {"timestamp":"2023-08-05T22:14:20.595039Z","level":"error","prefix":"ffmpeg/video","message":"mpeg2video: Invalid frame dimensions 0x0."} is normal for my files. This is related to how they are created.

Logs of faulty/error run:

[flutter_meedu_videoplayer] Fit is BoxFit.fill
[flutter_meedu_videoplayer] Last fit used was contain
[flutter_meedu_videoplayer] Fit is BoxFit.contain
NVIDIA GeForce RTX 2070
media_kit: ANGLESurfaceManager: Direct3D Feature Level: 11_0
1 1
media_kit: VideoOutput: Create Texture: 2743366984048
media_kit: VideoOutput: Using H/W rendering.
[log] {"timestamp":"2023-08-05T22:21:20.598706Z","level":"error","prefix":"libmpv_render/dxva2-egl","message":"Failed to create EGL surface"}
flutter: VideoOutput.Resize
flutter: {handle: 2742945406528, id: 2743366984048, rect: {height: 0, left: 0, top: 0, width: 0}}
flutter: NativeVideoController: Texture ID: 2743366984048
[log] {"timestamp":"2023-08-05T22:21:20.869972Z","level":"error","prefix":"ffmpeg/video","message":"mpeg2video: Invalid frame dimensions 0x0."}
[log] {"timestamp":"2023-08-05T22:21:20.869972Z","level":"error","prefix":"ffmpeg/video","message":"mpeg2video: Invalid frame dimensions 0x0."}
[log] {"timestamp":"2023-08-05T22:21:20.870976Z","level":"error","prefix":"ffmpeg/audio","message":"mp3float: Header missing"}
[log] {"timestamp":"2023-08-05T22:21:20.924889Z","level":"error","prefix":"ffmpeg/video","message":"mpeg2video: Invalid frame dimensions 0x0."}
[log] {"timestamp":"2023-08-05T22:21:21.629041Z","level":"error","prefix":"ffmpeg/audio","message":"mp2: Header missing"}
flutter: get
[log] {"timestamp":"2023-08-05T22:21:21.630040Z","level":"error","prefix":"ad","message":"Error decoding audio."}
[flutter_meedu_videoplayer] PlatformException(, Error decoding audio., null, null)
[flutter_meedu_videoplayer] 
[flutter_meedu_videoplayer] Fit is BoxFit.contain
1024 576
media_kit: VideoOutput: Free Texture: 2743366984048
media_kit: ANGLESurfaceManager: Direct3D Feature Level: 11_0
media_kit: VideoOutput: Create Texture: 2743489189568
flutter: VideoOutput.Resize
flutter: {handle: 2742945406528, id: 2743489189568, rect: {height: 576, left: 0, top: 0, width: 1024}}
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Bad state: Future already completed
#0      _AsyncCompleter.complete (dart:async/future_impl.dart:35:31)
#1      VideoPlayerController.initialize.eventListener (package:video_player/video_player.dart:445:33)
#2      _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#3      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#4      _DelayedData.perform (dart:async/stream_impl.dart:515:14)
#5      _PendingEvents.handleNext (dart:async/stream_impl.dart:620:11)
#6      _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:591:7)
#7      _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#8      _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)

MediaKitEventLoopHandler::Register: std::thread exit: 2742945406528
MediaKitEventLoopHandler::Dispose: 2742945406528
media_kit: VideoOutput: Free Texture: 2743489189568
VideoOutput::~VideoOutput: 2742945406528

I search a bit where the log message (and the PlatformException) came from, but found nothing related to meedu in the packages

abdelaziz-mahdy commented 11 months ago

Like I mentioned it came from media_kit will add the flag and let you know.

Vito0912 commented 11 months ago

I found a more or less suitable solution - in short-term. When creating a MeeduPlayerController it let´s you define an errorText. If you set it to '' the error messages will be overwritten by this. Sadly this also disables the controls for the video, so not optimal too.

abdelaziz-mahdy commented 10 months ago

hello, in 4.2.23, you can disable the throwing of the error in media_kit since its not valid in your case just use

  initMeeduPlayer(
    throwErrors: false
  );