UnityPlugin-AVProVideo icon indicating copy to clipboard operation
UnityPlugin-AVProVideo copied to clipboard

[Android] Invalid NAL length

Open TarikTKorp opened this issue 2 years ago • 2 comments

Describe the issue My Android application locally downloads videos from a remote server. When the video is downloaded over a "stable" internet connection (ADSL / Fiber / 4G with low ping), the file plays without any issues on the Android device. However, when the connection is not "stable" (4G with low bandwidth or high ping), I encounter the following error message 'Invalid NAL length' for the same downloaded file.

The file remains playable up to the problematic frame or if I play the video immediately after the problematic frame. When I resume playback of the corrupted file, the behavior is the same whether I choose MediaPlayer or ExoPlayer. Interestingly, the corrupted file is playable when directly played on the Unity editor.

AVPro's MediaPlayer using ExoPlayer does not generate any "Error" events. It is possible that AVPro handle the problem at least by throwing an error or better skip automatically the problematic frame and continue to read the file ?

Your Setup (please complete the following information):

  • Unity version: 2020.3.23f1
  • AVPro Video version (number and edition (trial/core/ultra/enterprise)): 2.90 Ultra
  • Operating system version: Android
  • Device model: Pico G2 4k
  • Video specs (resolution, frame-rate, codec, file size): 3840 x 1920 @30fps H.264 3.44 Go

To Reproduce

  1. Download a file with unstable connection
  2. Play the file with an Android device and Exoplayer

Logs Playback error 11-17 21:58:22.756 21707 21833 E ExoPlayerImplInternal: com.google.android.exoplr2avp.ExoPlaybackException: Source error 11-17 21:58:22.756 21707 21833 E ExoPlayerImplInternal: at com.google.android.exoplr2avp.ExoPlayerImplInternal.handleIoException(ExoPlayerImplInternal.java:684) 11-17 21:58:22.756 21707 21833 E ExoPlayerImplInternal: at com.google.android.exoplr2avp.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:654) 11-17 21:58:22.756 21707 21833 E ExoPlayerImplInternal: at android.os.Handler.dispatchMessage(Handler.java:102) 11-17 21:58:22.756 21707 21833 E ExoPlayerImplInternal: at android.os.Looper.loop(Looper.java:164) 11-17 21:58:22.756 21707 21833 E ExoPlayerImplInternal: at android.os.HandlerThread.run(HandlerThread.java:65) 11-17 21:58:22.756 21707 21833 E ExoPlayerImplInternal: Caused by: com.google.android.exoplr2avp.ParserException: Invalid NAL length{contentIsMalformed=true, dataType=1} 11-17 21:58:22.756 21707 21833 E ExoPlayerImplInternal: at com.google.android.exoplr2avp.extractor.mp4.Mp4Extractor.readSample(Mp4Extractor.java:654) 11-17 21:58:22.756 21707 21833 E ExoPlayerImplInternal: at com.google.android.exoplr2avp.extractor.mp4.Mp4Extractor.read(Mp4Extractor.java:266) 11-17 21:58:22.756 21707 21833 E ExoPlayerImplInternal: at com.google.android.exoplr2avp.source.BundledExtractorsAdapter.read(BundledExtractorsAdapter.java:133) 11-17 21:58:22.756 21707 21833 E ExoPlayerImplInternal: at com.google.android.exoplr2avp.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1047) 11-17 21:58:22.756 21707 21833 E ExoPlayerImplInternal: at com.google.android.exoplr2avp.upstream.Loader$LoadTask.run(Loader.java:420) 11-17 21:58:22.756 21707 21833 E ExoPlayerImplInternal: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) 11-17 21:58:22.756 21707 21833 E ExoPlayerImplInternal: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) 11-17 21:58:22.756 21707 21833 E ExoPlayerImplInternal: at java.lang.Thread.run(Thread.java:764)

Videos I can send you a corrupted file example

TarikTKorp avatar Nov 17 '23 22:11 TarikTKorp

Does the file play on android devices either on their own video player or on Unity's videoplayer?

Chris-RH avatar Nov 21 '23 10:11 Chris-RH

With the Pico player, the same video stops playback on the same frame, but the player skips that frame and attempts to resume from the next frame, continuing playback normally afterward. It would be great if AVPro could replicate this behavior and report the error in the "Error" event of the MediaPlayer.

Screencast Built-In Pico VideoPlayer

The Unity Player is currently experiencing significant audio distortion accompanied by a completely black screen.

TarikTKorp avatar Nov 21 '23 13:11 TarikTKorp

Hello AVPro Video team,

I wanted to follow up on the discussion regarding this issue that I opened some time ago. I understand that you may be busy with other tasks, but I was wondering if there has been any progress or updates regarding this issue.

I'm still very interested in resolving this issue as it has a significant impact on my current project. If you need any further information or details to move forward with this problem, please let me know.

Thank you very much for your attention and work on this project.

TarikTKorp avatar Mar 11 '24 08:03 TarikTKorp

If the file is corrupt it is not a valid video. Can we get the 'corrupted file' to take a look at? Also the original video please.

Have you tried playing the video back directly in the ExoPlayer demo? Send it over and we can do that if you don't have it to hand.

Maybe you could hash check it? Or perhaps another solution, use the caching feature in the Ultra edition of AVPro Video.

Ste-RH avatar Jun 10 '24 13:06 Ste-RH

Could you provide any more info please? You can email the media to [email protected]

Chris-RH avatar Jun 14 '24 08:06 Chris-RH

We shall be closing this issue soon due to a lack of response

Ste-RH avatar Jun 17 '24 10:06 Ste-RH

Hello,

We have tested the file exclusively with the ExoPlayer included in AVPro. We already manage to re-download the file when its size on disk is not correct to the byte. However, the problem occurs only with poor connections, and between the moment we start re-downloading the file and the moment it is actually replaced, several days or even weeks can pass during which users may still try to play the corrupted file. Our tool operates mostly offline.

I have sent the download link to your email for you to test on your end.

Best regards,

TarikTKorp avatar Jun 17 '24 10:06 TarikTKorp

Email received, thank you

Chris-RH avatar Jun 17 '24 10:06 Chris-RH

Hi,

  1. The issue seems to be caused by the download not restarting correctly after the connection has been lost. It may be an issue with server configuration. Are you able to provide a link to the video URL on the server that you are testing?
  2. It is a very large mp4 file. I would suggest converting it to HLS or DASH format. They would suit this use case.

Chris-RH avatar Jun 17 '24 11:06 Chris-RH

There is also the caching feature on Android that would fit well for your use-case. You can essentially stream play and/or download to local

Ste-RH avatar Jun 17 '24 13:06 Ste-RH

Have you had any luck with those suggestions?

Chris-RH avatar Jun 21 '24 06:06 Chris-RH