RenderHeads / UnityPlugin-AVProVideo

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

[#ULBnz] Android file offset is not working #65

Closed AndrewRH closed 5 years ago

AndrewRH commented 5 years ago

Describe the bug This is for using the feature from AVPro to read a hidden file in another file. I'm trying the solution you mentioned but for some reason it always plays the dummy video instead of the hidden video.

I did the same as the example explains at the documentation. I did a bat script that copies the real video inside the dummy video, in fact, the result is a file which its size is the combination of the two videos, the dummy + real. (So I guess that is fine) I put the offset (the dummy video size) at the editor place you said: MediaPlayer > Platform Specific > Android section.

I know that the offset is being properly read by AVPro because I can see it in the AVPro debug logs as "[AVProVideo] Opening file://sdcard/Android/data/Inflight/video-hidden.mp4 (offset 23563937)"

The very interesting thing here is that no matter what I put in the offset, it always shows the dummy video. Maybe, am I missing something?

I'm trying this directly inside the Android device. Not in editor. In the editor I get the dummy video as well, but I supposed that it is expected.

Your Setup (please complete the following information):

AndrewRH commented 5 years ago

We have replicated this issue. For us it seems to happen randomly. Sometimes it does manage to play the correction offset video.

Have you tried changing the Video API to MediaPlayer instead of ExoPlayer? This should definitely work. The problem seems to be with ExoPlayer.

We're still investigating the problem and will get back to you once we know more.

ennio-inflight commented 5 years ago

Hi, thanks for investigating the problem. I've tried with ExoPlayer configuration as well, but for me the ExoPlayer configuration "breaks" the player, and it will only show a black screen. Let me describe here my scenario/setup:

I hope this will help you.

AndrewRH commented 5 years ago

Interesting that ExoPlayer breaks things. Can you not play any videos at all using ExoPlayer, even our BigBuckBunny sample videos?

Perhaps there is a ADB LOG CAT you could attach here, from when ExoPlayer is used and fails?

Did you try changing the Video API to MediaPlayer from ExoPlayer? The file offset feature should definitely work in that. We haven't tested it on a Pico headset though as we don't have one...

Ste-RH commented 5 years ago

We are investigating a generic ExoPlayer playback bug that exhibits the black screen issue you describe.

I have tested the hidden video you emailed over with the offset of 23563937 bytes in our reference test player scene using both MediaPlayer API and an development version with some WIP ExoPlayer path fixes. Both playback the hidden video as it should be played. This has been tested on an NVidia Shield tablet, and a Samsung S7 (UK/EU version).

Have you tested on any other Android devices?

ennio-inflight commented 5 years ago

No, we only use the Pico Goblin 2 device. Since we are not going to use another device for our product it was not making sense to test it in another device. Logcat output was not displaying errors at all.

Ste-RH commented 5 years ago

Do you have any other devices you could test your code-base/plugin set-up on?

ennio-inflight commented 5 years ago

Sadly no, sorry, we only have the pico devices. I can send you the reference page for the device, maybe there you can find something useful about their specs https://www.pico-interactive.com/g2 It uses a snapdragon 835.

AndrewRH commented 5 years ago

That's so strange... As Ste said, for all of our devices it's working perfectly. I can't imagine what would be different on the Pico that would make it behave differently....

Ste-RH commented 5 years ago

Actually, I think the Oculus GO uses a snapdragon 835 (?). We have one in the office. I will test it on there...

Ste-RH commented 5 years ago

I can confirm that playback is as expected on the GO with both MediaPlayer and ExoPlayer API paths.

ennio-inflight commented 5 years ago

Well, that's odd. Thank you guys for checking. It is very strange in both scenarios, black screen with ExoPlayer API and not applying the Offset with MediaPlayer API... Next week I'll try to allocate some time to send you more logs. Also, we are planning to do a proper upgrade of our application by the end of next week. I'll try to bring you back more information once that is done.

Ste-RH commented 5 years ago

That's great. The more info you can provide, the more chance we can track down the issue.

The black screen ExoPlayer issue. I think this might be linked to another, more wide ranging ExoPlayer API path problem. We are looking to get a fix for this ASAP.

Ste-RH commented 5 years ago

We have just released Version 1.9.17, which has some Android API fixes including the 'black screen' issue when using the ExoPlayer API path. Maybe you could grab this version and check to see if the problem you are seeing has been addressed in either of the API paths?

ennio-inflight commented 5 years ago

Cool, sorry guys for taking time to answer. We were busy these last days with some migration for our current applications. I have the log for the exoplayer problem with Pico and the version 1.9.12 of AVPro:

[AVProVideo] Error: Loading failed. File not found, codec not supported, video resolution too high or insufficient system resources.

This was tested with a normal video (not the hidden ones) with both MediaPlayer API and ExoPlayer. With MediaPlayer video plays as normal. With ExoPlayer we see the log error I put above.

I'm going to try the new version of AVPro as soon as possible to check if this error persists. Thank you.

ennio-inflight commented 5 years ago

Hi again, we just tried the new AVPro version 1.9.17 with Exoplayer API mode and we are getting exactly the same error I posted above in Pico device. [AVProVideo] Error: Loading failed. File not found, codec not supported, video resolution too high or insufficient system resources. By the way, besides this we have another question related to Exoplayer API. It is required to use Exoplayer API to reproduce MKV videos in Android? we were doing some tests and we had a problem with a mkv video that was not playing in Android with MediaPlayer API. Thanks again.

Ste-RH commented 5 years ago

Maybe you could try our sample video? The offset is 3542 bytes. I have had to zip it in order to attach it here. Please unzip the MP4 and assign it to your MediaPlayer object for testing.

BigBuckBunny_720p30-hidden.zip

ennio-inflight commented 5 years ago

Hi again, I've tried the mp4 you sent, I'm getting these messages in the log: 06-21 12:43:55.967 9722 9754 I Unity : [AVProVideo] Opening file://storage/emulated/0/Android/data/com.picovr.vrlauncher/files/../../Inflight/BigBuckBunny_720p30-hidden.mp4 (offset 3542) 06-21 12:43:56.198 9722 9754 I Unity : [AVProVideo] Using playback path: MediaPlayer NonOES (128x128@30.00) 06-21 12:43:56.199 9722 9754 I Unity : [AVProVideo] Texture ID: 86 06-21 12:43:59.373 9722 9754 I Unity : [AVProVideo] Shutdown and then the application closes. I hope this log helps a little bit more with that.

Ste-RH commented 5 years ago

Thanks for that. Very strange. Can you send over the log you get when using ExoPlayer API path please?

ennio-inflight commented 5 years ago

Sure, with exoplayer api: 06-21 13:10:10.088 11024 11054 I Unity : [AVProVideo] Opening file://storage/emulated/0/Android/data/com.picovr.vrlauncher/files/../../Inflight/BigBuckBunny_720p30-hidden.mp4 (offset 3542) 06-21 13:10:15.456 11024 11054 E Unity : [AVProVideo] Error: Loading failed. File not found, codec not supported, video resolution too high or insufficient system resources.

I think is the same one I posted some days ago sadly.

ennio-inflight commented 5 years ago

It is possible that the problem is the Pico device itself? Maybe a problem with the internal libraries for exoplayer, etc?

Ste-RH commented 5 years ago

Oki, thanks.

Hmm, it is very strange. We have tried to reproduce the issue on every Android device we can lay our hands on. We have looked at trying to get a Pico in the UK, but cannot find anywhere that can sell us one. If only we could get our hands on one for a few days!

One thing that looks a little odd from your log is the instances of '../'. That could certainly be a suggestion of why you are seeing issues. It looks like you are not loading the video out of the StreamingAssets folder?

ennio-inflight commented 5 years ago

Next week we are going to talk about DRM and some other solutions, I'll answer as soon as I can next week in order to let you now if we are going to continue with the solution of the hidden files or not. Maybe if they want to continue with it we can try to solve the problem about the pico device.

About the '../' I don't know if this should be something to worry about (unless you mean that this will have problems when you do the offset logic or something) because this is the way we do it in our current projects, and it works fine with everything we have.

Again thank you so much for all your help with this guys!

Ste-RH commented 5 years ago

No need to thank us, we are all on the same team :) Striving to make the best software we can.

So are you not loading out of StreamingAssets? If not, can you try that so we can eliminate the path as an issue? I have a hunch this might be the root of the problem!

ennio-inflight commented 5 years ago

Nope, we must read from outside the project, the media is stored in the sdcard of the device. I can try putting it in the StreamingAssets if you want to check if the problem disappears, sadly that won't help for our solution hahaha. Let me try 😄

Ste-RH commented 5 years ago

Yes, definitely try that if you can...so we can rule it in/out! If it works out of StreamingAssets it will give us a pointer as to how I might reproduce it here...then...hopefully...a fix!

ennio-inflight commented 5 years ago

Yes! it works if the movie is loaded from the StreamingAssets, but it does not work from outside (SDCard).

Ste-RH commented 5 years ago

Cool! We have a lead! Leave it with us :)

AndrewRH commented 5 years ago

@ennio-inflight did you try setting the Write Permission in Player Settings to External? This should grant read access as well to SDCARD.

ennio-inflight commented 5 years ago

@AndrewRH yes, otherwise our product does not work 😄. This option is always set to External in our products.

AndrewRH commented 5 years ago

Okay thanks, just had to rule that out :) We'll continue looking out our side....

AndrewRH commented 5 years ago

I believe @RenderHeadsSte has this working now in his internal testing..I'm sure he'll share information soon.

Ste-RH commented 5 years ago

I can indeed.

I have addressed the issue of loading from local storage and external sd-card with a file offset on the ExoPlayer API path. The MediaPlayer API path works here without code change. I am not sure why you are seeing the issue when using the MediaPlayer API path (EDIT: I seen you it is because you are using MKV files that don't playback in MediaPlayer).

We hope to have the fix for this in the ExoPlayer API path released in version >= 1.9.18.