RenderHeads / UnityPlugin-AVProVideo

AVPro Video is a multi-platform Unity plugin for advanced video playback
https://www.renderheads.com/products/avpro-video/
224 stars 27 forks source link

[Android] Fatal Crash when trying to play codec unsupported by android hardware #1905

Closed BoTiKu closed 3 days ago

BoTiKu commented 1 week ago

When extract frame from a video and starting the video, errors occur, which ultimately lead to a fatal crash of the entire program.

Setup:

To Reproduce

  1. Launch one of the videos

Logs

Before fatal crash: 2024.06.19 14:49:11.833 31784 32291 Info Unity [AVProVideo] Opening file:////storage/emulated/0/Android/data/com.ScientificEntertainment.SchoolDrozdov/files/image/temp/202406180938452027160412.ogv (offset 0) with API MediaPlayer 2024.06.19 14:49:11.833 31784 32291 Info Unity UnityEngine.Logger:Log(LogType, Object, Object) 2024.06.19 14:49:11.833 31784 32291 Info Unity UnityEngine.Debug:Log(Object, Object) 2024.06.19 14:49:11.833 31784 32291 Info Unity RenderHeads.Media.AVProVideo.MediaPlayer:InternalOpenMedia() 2024.06.19 14:49:11.833 31784 32291 Info Unity ExtractorVideoFrame:PickAnyFrame(String) 2024.06.19 14:49:11.833 31784 32291 Info Unity <SetVideoData>d__17:MoveNext() 2024.06.19 14:49:11.833 31784 32291 Info Unity System.Runtime.CompilerServices.AsyncVoidMethodBuilder:Start(TStateMachine&) 2024.06.19 14:49:11.833 31784 32291 Info Unity LessonElementFactRequestGUI:SetVideoData() 2024.06.19 14:49:11.833 31784 32291 Info Unity LessonElementFactRequestGUI:SetData(Object) 2024.06.19 14:49:11.833 31784 32291 Info Unity LessonElementPlayerGUI:SetContent(LessonElementCardGUI, CardsAppSchoolTestGUI, LessonElementFactRequestGUI, LessonElementTestRequestGUI, LessonElementPupilSlideGUI) 2024.06.19 14:49:11.833 31784 32291 Info Unity LessonElementGUI:InitElement(Object) 2024.06.19 14:49:11.833 31784 32291 Info Unity LessonElementPlayerGUI:SetData(Object) 2024.06.19 14:49:11.833 31784 32291 Info Unity CardsAppPleerLessonView:SetUp(Int32) 2024.06.19 14:49:11.833 31784 32291 Info Unity CardsAppPleerLessonView:set_DataElements(List1) 2024.06.19 14:49:11.833 31784 32291 Info Unity <>c__DisplayClass96_0:g__AfterLoadUnknownElements|0() 2024.06.19 14:49:11.833 31784 32291 Info Unity StartLessonByScheduleGUI:GoToLesson() 2024.06.19 14:49:11.833 31784 32291 Info Unity UnityEn 2024.06.19 14:49:11.841 31784 975 Verbose MediaPlayer-JNI setDataSourceFD: fd 138 2024.06.19 14:49:11.841 31784 975 Verbose MediaPlayerNative setDataSource(138, 0, 576460752303423487)

2024.06.19 14:49:11.853 31784 975 Verbose MediaExtractorFactory MediaExtractorFactory::Create (null) 2024.06.19 14:49:11.853 31784 975 Verbose MediaExtractorFactory get service manager 2024.06.19 14:49:11.876 31784 975 Verbose MediaPlayer-JNI setLooping: 0 2024.06.19 14:49:11.876 31784 975 Verbose MediaPlayerNative MediaPlayer::setLooping 2024.06.19 14:49:11.876 31784 975 Verbose MediaPlayerNative setVideoSurfaceTexture 2024.06.19 14:49:11.877 31784 975 Verbose MediaPlayerNative prepareAsync 2024.06.19 14:49:11.892 31784 31802 Verbose MediaPlayerNative message received msg=100, ext1=1, ext2=-2147483648 2024.06.19 14:49:11.892 31784 31802 Error MediaPlayerNative error (1, -2147483648) 2024.06.19 14:49:11.892 31784 31802 Verbose MediaPlayerNative callback application 2024.06.19 14:49:11.892 31784 31802 Verbose MediaPlayerNative back from callback 2024.06.19 14:49:12.164 31784 32291 Error MediaPlayer Error (1,-2147483648)

`

Fatal crash: `2024.06.19 14:54:36.340 31784 32291 Info Unity [AVProVideo] Opening file:////storage/emulated/0/Android/data/com.ScientificEntertainment.SchoolDrozdov/files/image/temp/20240618093919-1610224714.webm (offset 0) with API MediaPlayer 2024.06.19 14:54:36.340 31784 32291 Info Unity UnityEngine.Logger:Log(LogType, Object, Object) 2024.06.19 14:54:36.340 31784 32291 Info Unity UnityEngine.Debug:Log(Object, Object) 2024.06.19 14:54:36.340 31784 32291 Info Unity RenderHeads.Media.AVProVideo.MediaPlayer:InternalOpenMedia() 2024.06.19 14:54:36.340 31784 32291 Info Unity ExtractorVideoFrame:PickAnyFrame(String) 2024.06.19 14:54:36.340 31784 32291 Info Unity d17:MoveNext() 2024.06.19 14:54:36.340 31784 32291 Info Unity System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean) 2024.06.19 14:54:36.340 31784 32291 Info Unity System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object, Boolean) 2024.06.19 14:54:36.340 31784 32291 Info Unity System.Runtime.CompilerServices.MoveNextRunner:Run() 2024.06.19 14:54:36.340 31784 32291 Info Unity UniRx.Async.UniTaskCompletionSource:TrySetResult() 2024.06.19 14:54:36.340 31784 32291 Info Unity d27:MoveNext() 2024.06.19 14:54:36.340 31784 32291 Info Unity UniRx.Async.UniTaskCompletionSource:TrySetResult() 2024.06.19 14:54:36.340 31784 32291 Info Unity d__0:MoveNext() 2024.06.19 14:54:36.340 31784 32291 Info Unity UniRx.Async.Internal.ReusablePromise:TrySetResult() 2024.06.19 14:54:36.340 31784 32291 Info Unity UniRx.Async.DelayPromise:MoveNext() 2024.06.19 14:54:36.340 31784 32291 Info Unity UniRx.Async.Internal.PlayerLoopRunner:Run()

2024.06.19 14:54:36.343 31784 31802 Verbose MediaPlayerNative notify(8, 0, 0) callback on disconnected mediaplayer 2024.06.19 14:54:36.343 31784 1243 Verbose MediaPlayer resetDrmState: mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false 2024.06.19 14:54:36.343 31784 1243 Verbose MediaPlayer cleanDrmObj: mDrmObj=null mDrmSessionId=null 2024.06.19 14:54:36.372 31784 1244 Verbose MediaPlayer-JNI setDataSourceFD: fd 149 2024.06.19 14:54:36.372 31784 1244 Verbose MediaPlayerNative setDataSource(149, 0, 576460752303423487) 2024.06.19 14:54:36.376 31784 1244 Warn ClearFileSource offset/length adjusted from 0/576460752303423487 to 0/384986 2024.06.19 14:54:36.376 31784 1244 Verbose MediaExtractorFactory MediaExtractorFactory::Create (null) 2024.06.19 14:54:36.377 31784 1244 Verbose MediaExtractorFactory get service manager 2024.06.19 14:54:36.407 31784 1244 Verbose MediaPlayer-JNI setLooping: 0 2024.06.19 14:54:36.407 31784 1244 Verbose MediaPlayerNative MediaPlayer::setLooping 2024.06.19 14:54:36.407 31784 1244 Verbose MediaPlayerNative setVideoSurfaceTexture 2024.06.19 14:54:36.407 31784 1244 Verbose MediaPlayerNative prepareAsync 2024.06.19 14:54:36.428 31784 31802 Verbose MediaPlayerNative message received msg=5, ext1=960, ext2=540 2024.06.19 14:54:36.428 31784 31802 Verbose MediaPlayerNative New video size 960 x 540 2024.06.19 14:54:36.428 31784 31802 Verbose MediaPlayerNative callback application 2024.06.19 14:54:36.428 31784 31802 Verbose MediaPlayerNative back from callback 2024.06.19 14:54:36.429 31784 31802 Verbose MediaPlayerNative message received msg=200, ext1=10972, ext2=0 2024.06.19 14:54:36.429 31784 31802 Warn MediaPlayerNative info/warning (10972, 0) 2024.06.19 14:54:36.429 31784 31802 Verbose MediaPlayerNative callback application 2024.06.19 14:54:36.429 31784 31802 Verbose MediaPlayerNative back from callback 2024.06.19 14:54:36.430 31784 31801 Verbose MediaPlayerNative message received msg=200, ext1=10953, ext2=0 2024.06.19 14:54:36.430 31784 31801 Warn MediaPlayerNative info/warning (10953, 0) 2024.06.19 14:54:36.430 31784 31801 Verbose MediaPlayerNative callback application 2024.06.19 14:54:36.430 31784 31801 Verbose MediaPlayerNative back from callback 2024.06.19 14:54:36.430 31784 31801 Verbose MediaPlayerNative message received msg=1, ext1=0, ext2=0 2024.06.19 14:54:36.430 31784 31801 Verbose MediaPlayerNative MediaPlayer::notify() prepared 2024.06.19 14:54:36.430 31784 31801 Verbose MediaPlayerNative callback application 2024.06.19 14:54:36.430 31784 31801 Verbose MediaPlayerNative back from callback 2024.06.19 14:54:36.436 31784 32291 Verbose MediaPlayerNative setVideoSurfaceTexture 2024.06.19 14:54:36.444 31784 32291 Verbose MediaPlayer-JNI getCurrentPosition: 0 (msec) 2024.06.19 14:54:36.447 31784 32291 Verbose MediaPlayerNative invoke 72 2024.06.19 14:54:36.451 31784 32291 Verbose MediaPlayerNative getDuration_l 2024.06.19 14:54:36.452 31784 32291 Verbose MediaPlayer-JNI getDuration: 13346 (msec) 2024.06.19 14:54:36.452 31784 32291 Verbose MediaPlayerNative invoke 72 0001.01.01 00:00:00.000 -1 -1 Info --------- beginning of crash 2024.06.19 14:54:36.458 31784 32291 Error AndroidRuntime FATAL EXCEPTION: UnityMain 2024.06.19 14:54:36.458 31784 32291 Error AndroidRuntime Process: com.ScientificEntertainment.SchoolDrozdov, PID: 31784 2024.06.19 14:54:36.458 31784 32291 Error AndroidRuntime java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference 2024.06.19 14:54:36.458 31784 32291 Error AndroidRuntime at android.media.MediaFormat.getInteger(MediaFormat.java:1211) 2024.06.19 14:54:36.458 31784 32291 Error AndroidRuntime at com.renderheads.AVPro.Video.Player_MediaPlayer.onPrepared(Unknown Source:278) 2024.06.19 14:54:36.458 31784 32291 Error AndroidRuntime at android.media.MediaPlayer$EventHandler.handleMessage(MediaPlayer.java:4118) 2024.06.19 14:54:36.458 31784 32291 Error AndroidRuntime at android.os.Handler.dispatchMessage(Handler.java:107) 2024.06.19 14:54:36.458 31784 32291 Error AndroidRuntime at android.os.Looper.loop(Looper.java:237) 2024.06.19 14:54:36.458 31784 32291 Error AndroidRuntime at com.unity3d.player.UnityPlayer$F.run(Unknown Source:24) `

Videos

  1. https://filesamples.com/samples/video/ogv/sample_960x400_ocean_with_audio.ogv
  2. https://filesamples.com/samples/video/webm/sample_960x540.webm
Chris-RH commented 1 week ago

Are you trying to do this while the video is playing? ExtractFrame is only for non-playing videos, as it involves seeking. Make sure autoplay is disables. After the ReadyToPlay event, call:

Texture frame = mediaPlayer.ExtractFrame(10.0); That would extract a frame at time 10s

BoTiKu commented 1 week ago

I stop the video playback, and pull out the frame by the Media Player Event.EventType.ReadyToPlay. And when using videos in mp4 or M4V format, I don't have any errors. The frame is successfully taken and the video is successfully played. But if I take the two videos above, then I have a crash of the entire application.

There are no errors in the Unity editor and in the build on my Windows 10 when playing these videos. It's only on Android.

BoTiKu commented 1 week ago

Full logs. First, I started 2 videos that played back without error and was also successful in taking a frame. Then I launched 2 videos from the list, video format .ogv was not played and it was not possible to take a frame. Video format .webm generally led to the crash of the program.

Full logs with error.txt

Chris-RH commented 1 week ago

The problem is that your phone hardware is unable to decode the codecs used in those videos.

Is it just when you try to extract the frame that it crashes, or is it when you try to play it as well?

BoTiKu commented 1 week ago

Yes, I get a fatal error when trying to play a video. Now I have not made any attempts to extract the frame. Crash when starting a video.txt

If I extract only the frame, I also get an error and crash the application. Crash when only pick frame.txt

Is there any way I can find out in advance through your plugin that this video will not be supported on the current device? I need this to show the user information that this video is not supported on his device.

MorrisRH commented 1 week ago

The media player should now report loading as failed when the codec is not support. This fix will make it into the next release (version 3.0.4)

Chris-RH commented 1 week ago

AVPro Video version 3.0.4 has been released. Please let us know if it has not fixed your issue.