Search Unity

[Released] AVPro Video - complete video playback solution

Discussion in 'Assets and Asset Store' started by AndrewRH, Feb 12, 2016.

  1. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Posts:
    2,806
    If you're not doing anything fancy like stereo or transparent packing, then you don't need to use one of our shaders - you can just use any standard Unity shader and use the ApplyToMaterial or ApplyToMesh (better) component to apply the video texture to that material.

    If you do need these advanced features, then a custom shader is required. It shouldn't be difficult to add transparency support to the Lit-Diffuse shader, or to add lighting support to the Unlit-Transparent shader. If you can't do this yourself then let me know which material features you need and we can write this shader for you.

    Thanks,
     
  2. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Posts:
    2,806
    Hi,

    We've never tries doing a continuous feed before over progressive HTTP - only fixed length files. We can certainly test it out on our side.

    If your use case allows for 3rd party codecs, and you're using Windows, you could set the video API to DirectShow (on the MediaPlayer component, under Platform Specific > Windows panel) and install LAV Filters which may give better results for continuous MPEG-TS...

    Which platform and OS version is this on?

    Thanks,
     
    DarkMio likes this.
  3. HarryE22

    HarryE22

    Joined:
    May 20, 2013
    Posts:
    12
    Yes, we are using Transparent Packing, I'm afraid. We tried to add lighting to the Transparent shader, but didn't make much progress. If you're willing to write the shader, that would be a huge help!
     
  4. Cambesa

    Cambesa

    Joined:
    Jun 6, 2011
    Posts:
    119
    Thank you very much, answer 2 gave us a lot of food for thought!

    I've followed your advice and tried the tinting red when OES is used(and tinting green when the fallback is used) and it seems that both the Samsung S5 and S6 use the fallback(both coloring green) even though "Use Fast OES Path" is set to true, is there anything I'm missing? I'm using the shader:
    "AVProVideo/Unlit/Opaque (texture+color support) - Android OES ONLY"
    as main shader and as fallback I'm using:
    "AVProVideo/Unlit/Opaque (texture+color+fog+stereo support)"

    Thanks
     
  5. DarkMio

    DarkMio

    Joined:
    Feb 10, 2016
    Posts:
    7
    We're running this on Mac OS X, Windows, WinRT (HoloLens), iOS - Android is an option, but currently not in our scope.
    I believe I had success with Windows once, but I don't recall exactly anymore.

    Best regards
     
  6. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Posts:
    2,806
    I guess it's using the fallback shader because its failing to compile the GLSL shader on the Android device.
    I know there is a problem with OES support in Unity 5.6.0f3 with some Android devices. Is there anythign in the adb log?
    Which version of Unity and AVPro Video are you using?
    Thanks,
     
  7. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Posts:
    2,806
    Oh wow...all of those platforms :) So....are you getting this same behaviour on all of those? Is there a preferred platform that we can start testing with?

    Thanks,
     
  8. DarkMio

    DarkMio

    Joined:
    Feb 10, 2016
    Posts:
    7
    OSX and HoloLens are our highest priority platforms right now.
    Thanks for your time!
     
  9. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Posts:
    2,806
    Hi All,

    AVPro Video version 1.6.4 has just been released!

    You can find the updated version on the Asset Store and the free trial version / demos on our website.

    Changes include:

    Windows desktop
    • Fixed an intermittent bug introduced in version 1.6.2 which caused videos to sometimes not appear or to appear black
    Thanks,
     
  10. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Posts:
    2,806
    Hi HarryE22,

    Try the shader attached here - it should support both lighting and alpha packing at the same time.

    Thanks,
     

    Attached Files:

  11. Cambesa

    Cambesa

    Joined:
    Jun 6, 2011
    Posts:
    119
    I'm using Unity 5.6.0f3 and AVPro 1.6.3. I had the same problem on earlier versions of Unity.
    The adb log has a lot(when using: "adb logcat -s Unity")

    I attached a file with logs that might be relevant and here's are some of the most potential problems:

    Samsung S5:
    05-08 10:31:02.962 9747 9963 D Unity : -------- failed compiling:
    05-08 10:31:02.962 9747 9963 D Unity : vertex shader
    05-08 10:31:02.962 9747 9963 D Unity : 0:3: P0003: Extension 'GL_OES_EGL_image_external_essl3' not supported
    05-08 10:31:02.962 9747 9963 D Unity : 0:41: L0002: No matching function for call to 'TRANSFORM_TEX'

    05-08 10:31:02.987 9747 9963 D Unity : -------- failed compiling:
    05-08 10:31:02.987 9747 9963 D Unity : fragment evaluation shader
    05-08 10:31:02.987 9747 9963 D Unity : 0:3: P0003: Extension 'GL_OES_EGL_image_external_essl3' not supported
    05-08 10:31:02.987 9747 9963 D Unity : 0:7: S0032: no default precision defined for variable
    05-08 10:31:02.987 9747 9963 D Unity : Note: Creation of internal variant of shader 'AVProVideo/Unlit/Opaque (texture+color support) - Android OES ONLY' failed.
    05-08 10:31:03.017 9747 9767 D Unity : WARNING: Shader
    05-08 10:31:03.017 9747 9767 D Unity : Unsupported: 'AVProVideo/Unlit/Opaque (texture+color support) - Android OES ONLY' - Pass '' has no vertex shader

    Samsung S6:
    05-08 11:13:34.371 21961 22186 D Unity : -------- failed compiling:
    05-08 11:13:34.371 21961 22186 D Unity : vertex shader
    05-08 11:13:34.371 21961 22186 D Unity : 0:3: P0003: Warning: Extension 'GL_OES_EGL_image_external_essl3' not supported
    05-08 11:13:34.371 21961 22186 D Unity : 0:1: Warning: GL_OES_EGL_image_external is deprecated in ESSL 3 and later versions
    05-08 11:13:34.371 21961 22186 D Unity : 0:41: L0002: No matching function for call to 'TRANSFORM_TEX'

    What scares me the most is: Warning: GL_OES_EGL_image_external is deprecated in ESSL 3 and later versions

    Does that mean they actually don't and won't support OES at all anymore or does that mean that there is a replacement function I should use? Perhaps by fixing the vertex part, the fragment part might work again. Or maybe we can force the use of I'm not the best shader programmer but understand it a bit, mainly worked with HLSL though.
     

    Attached Files:

    Last edited: May 8, 2017
  12. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Posts:
    2,806
    Hi,
    No OES is still supported. There is a bug in Unity 5.6.0 which is preventing our GLSL shaders from compiling. I have reported it to Unity but I think the bug has a very low priority. Please go vote for the bug to be fixed here:

    Everyone go vote for Unity to fix this bug:
    https://issuetracker.unity3d.com/is...er-compilation-failure-on-some-mobile-devices

    You should have better luck if you use Unity 5.5.3...

    Thanks,
     
  13. Cambesa

    Cambesa

    Joined:
    Jun 6, 2011
    Posts:
    119
    Thanks, my colleague and me voted for the bug.

    I've downgraded back to Unity 5.5.3 and the errors have disappeared from the adb log, however it still uses the fallback shader, what could cause this? Tested on Samsung S6. It does show the shader in adb but no associated error when development build is turned off.

    Running it with "Development build" enabled returned the errors:

    05-08 17:49:02.661 19241 19767 D Unity : -------- failed compiling:
    05-08 17:49:02.661 19241 19767 D Unity : vertex shader
    05-08 17:49:02.661 19241 19767 D Unity : 0:4: P0003: Warning: Extension 'GL_OES_EGL_image_external_essl3' not supported
    05-08 17:49:02.661 19241 19767 D Unity : 0:1: Warning: GL_OES_EGL_image_external is deprecated in ESSL 3 and later versions
    05-08 17:49:02.661 19241 19767 D Unity : 0:41: L0002: No matching function for call to 'TRANSFORM_TEX'

    and

    05-08 17:49:02.661 19241 19767 D Unity : -------- failed compiling:
    05-08 17:49:02.661 19241 19767 D Unity : fragment evaluation shader
    05-08 17:49:02.661 19241 19767 D Unity : 0:4: P0003: Warning: Extension 'GL_OES_EGL_image_external_essl3' not supported
    05-08 17:49:02.661 19241 19767 D Unity : 0:1: Warning: GL_OES_EGL_image_external is deprecated in ESSL 3 and later versions
    05-08 17:49:02.661 19241 19767 D Unity : 0:47: S0004: Arithmetic operations not allowed on this type
    05-08 17:49:02.661 19241 19767 D Unity :
    05-08 17:49:02.661 19241 19767 D Unity : Note: Creation of internal variant of shader 'AVProVideo/Unlit/Opaque (texture+color support) - Android OES ONLY' failed.
    05-08 17:49:02.671 19241 19281 D Unity : WARNING: Shader
    05-08 17:49:02.671 19241 19281 D Unity : Unsupported: 'AVProVideo/Unlit/Opaque (texture+color support) - Android OES ONLY' - Pass '' has no vertex shader

    After these errors above, it repeats this next error as long as the app runs:
    05-08 17:49:04.171 19241 19767 E Unity : OPENGL NATIVE PLUG-IN ERROR: GL_INVALID_OPERATION: Operation illegal in current state
    05-08 17:49:04.171 19241 19767 E Unity :
    05-08 17:49:04.171 19241 19767 E Unity : (Filename: ./Runtime/GfxDevice/opengles/GfxDeviceGLES.cpp Line: 299)
     
    Last edited: May 8, 2017
  14. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Posts:
    2,806
    hmm strange - are you using the latest AVPro Video (1.6.4)?
     
  15. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Posts:
    2,806
    Actually..please replace that shader with the fixed version attached. Thanks,
     

    Attached Files:

  16. Cambesa

    Cambesa

    Joined:
    Jun 6, 2011
    Posts:
    119
    It works! Thank you very much!

    These changes solved it?
    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
    //texVal = TRANSFORM_TEX(gl_MultiTexCoord0.xy, _MainTex);
    texVal = gl_MultiTexCoord0.xy;
    //texVal.x = 1.0 - texVal.x;
    texVal.y = 1.0 - texVal.y;
     
    Last edited: May 9, 2017
  17. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Posts:
    2,806
    Yes, for some reason it didn't like TRANSFORM_TEX saying it is undefined, when it is actually defined in Unitys own UnityCG.glslinc file...So that might be another Unity bug I need to report... I still don't think it will work in Unity 5.6.0 though.
     
  18. 785130190

    785130190

    Joined:
    May 11, 2017
    Posts:
    21
    unity crashed when I switch the video file using MediaPlayer.OpenVideoFromFile.....
    unity 5.3.5 avpro video 1.5.12....render with NGUI
     
  19. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Posts:
    2,806
    Hi,

    Please upgrade to a newer version of the Plugin (it's free upgrade via the Asset Store). We have fixed the NGUI script (and many other improvements) in newer version.

    Thanks,
     
  20. 785130190

    785130190

    Joined:
    May 11, 2017
    Posts:
    21
    UnityPlugin-AVProVideo-Latest-Trial.unitypackage...is this? I'll have a try. thanks!
     
  21. 785130190

    785130190

    Joined:
    May 11, 2017
    Posts:
    21
    It's the same:(. It doesn't work!It seems like crash happened when I change the video file without stop the video!
     
  22. 785130190

    785130190

    Joined:
    May 11, 2017
    Posts:
    21
    There is a pattern.After I open a video and play it,then I pause it,switch video,finally I play it or set loop,the editor will crash.I tried many times,all the same.
     
    Last edited: May 12, 2017
  23. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Posts:
    2,806
    Which version of Unity?
    Which version of AVPro Video?
    Which platform? :)
     
  24. Mastrom

    Mastrom

    Joined:
    Dec 17, 2013
    Posts:
    4
    Hi, I have a very rare problem ...

    I need to play a 360 stereo video.

    If the application starts in the scene with the 360 video, the stereo looks correctly.

    BUT, I'm in a scene (for example a menu), and then I open another scene with the 360 video, for some strange reason, the video only looks mono, in 2 eyes the same half of the video.

    Versions I use:
    Unity 5.6.0f3
    AVPro video: 1.6.4
    Oculus OVR Plugin: 1.14.0


    Do you have any idea what's going on?

    Thank you very much
     
  25. Tom-Goethals

    Tom-Goethals

    Joined:
    Mar 6, 2015
    Posts:
    102
    Going totally crazy with Unity 5.6.0, the native VR, switching from cardboard to magic window and back is just totally broken randomly crashing even in the most simple of test projects.

    What version of Unity would you guys recommend to roll back to?

    I need:
    OES to work.
    Cardboard on and off switching
     
  26. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Posts:
    2,806
    I'm not sure - sounds like some debugging is in order.
    1) Maybe first try to test for sure that its mono - use one of our sample Alpha side-by-side or top-bottom videos - this should show clearly whether it's showing both eyes.

    2) Once this is verified, then make sure the MediaPlayer component has the correct Stereo packing mode set

    3) Then check that the mesh has the correct material assigned - only that supports stereo

    4) Next check that the UpdateStereoCamera component is in your scene and that it's pointing to the correct camera in your scene.

    If you're still stuck, you can send us your scene to debug.

    Thanks,
     
  27. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Posts:
    2,806
    Yeah I feel your pain.. Still waiting for the GLSL shader support to be fixed in 5.6.x....
    I don't know which verson of Unity support Cardboard on/off switching, but I know AVPro Video 1.6.4 has OES support in Unity 5.5.3

    Thanks,
     
  28. lucasTOG

    lucasTOG

    Joined:
    Oct 12, 2016
    Posts:
    7
    Hi Team,

    We have upgraded the AVProVideo plugin to the lastest version and Unity to 5.6.0p2, and we have noted that sometimes (and randomly) the loading of a video fails with the following error:

    Loading failed. Possible codec not supported, video resolution too high or insufficient system resources.

    No code was changed and the video files are the same.

    Do you have any idea of what may be causing this?

    Let me know if you need further information!

    Thanks!
     
  29. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Posts:
    2,806
    Yes please, further information :)
    1) Which platform is this on?
    2) Can you confirm in the console that it's printing version 1.6.4?
    3) Are you using D3D11? (says so in Window title)
    4) Does this happen in editor only? or build only? or both?
    5) What resolution are you videos?
    6) Tried updating GPU drives?
    7) Does it happen in our sample scenes too?

    Thanks,
     
  30. 785130190

    785130190

    Joined:
    May 11, 2017
    Posts:
    21
    Unity5.3.5Pro,AVProVideo latest trial,Windows 7,64bit.
    I find a solution,even not very good.Before I pause switch play video, I disable the parent GameObject and then enable parent GameObject,there is no crash.It's strange.I don't know why,but it worked.
     
  31. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Posts:
    2,806
    That's so strange.. I can't replicate that behaviour here. Does it crash also using our sample scenes? Like try "02_Demo_imGui" and see if you can switch video.

    Perhaps you could show the code you're using to switch video?

    Thanks,
     
  32. 785130190

    785130190

    Joined:
    May 11, 2017
    Posts:
    21
    OK,I'll give you the code later.
    And,there is another error,maybe not a error,video will stop for a while(about 0.05s) or play back a little when I change the play rate. Maybe I change it too often.I'm developing a video game. the video's rate will be changed by character's run speed.and character's speed changes at any time.
     
  33. HarryE22

    HarryE22

    Joined:
    May 20, 2013
    Posts:
    12
    This works great! Thank you for the help! :)
     
  34. Selaphiel

    Selaphiel

    Joined:
    Jan 31, 2014
    Posts:
    23
    We are also getting same, with Unity 5.6.0p2 and building for android, on editor there is no error. Also i have another question - So i am running a 360 stereo video on a sphere and inside the sphere there is a plane where i want to run the planar video, this all works in editor and other builds but not in android(throws the error decode failed), my 360 video is 4k with top down and planar video is 720p. Can you tell me how should i do it and which encoding should i use ? Currently the video is H.264 and 1280x720 and .mp4.
     
    Last edited: May 15, 2017
  35. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Posts:
    2,806
    The first issue - I'm not sure what is causing this to fail to load a video randomly. Are you using a single MediaPlayer when this happens or multiple?

    On Android it's best to use a single MediaPlayer - especially when you're dealing with 4K video. The devices only have limited resources and 4K video playback uses up a lot those resources, which can prevent other videos from loading. Perhaps you could send us your Unity project so we can test it here and try to fix the issue?

    I suspect your 720 planar video is having the same issue, related to resource usage. You may need to slightly lower your 4K video resolution (like 3840x1920 instead of 3840x2160, or perhaps even lower). There are also memory taking techniques you can use, such as running with a 16-bit back buffer, and disabling your depth/stencil buffer..You can also go to Graphics Settings and strip out unused features and shaders.

    Perhaps you could send us your Unity project that is exhibiting this random loading failing so we can test it here and try to fix the issue?

    Thanks,
     
    Selaphiel likes this.
  36. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Posts:
    2,806
    If you're changing the video speed often then you need to check a few things for best results:
    1) ideally the video shouldn't have any audio, as this can slow down changes to the playback rate.
    2) ideally the video should be compressed with key-frames only. Using P or B frames will slow down the playback rate changes
    3) ideally the video should be encoded as simply as possible to give the best performance - this includes disabling CABAC and using the fastdecode profile when encoding
    4) if your Platform is Mac or Windows desktop, then you may consider a fast codec such as Hap

    Another option to changing the playback rate is to pause the video and manually scrub through it by changing the time of the video. This often works best.

    I hope that helps
     
  37. vrglobal

    vrglobal

    Joined:
    May 15, 2017
    Posts:
    2
    Hi,
    I have problem with video frame rate on Android device. Frames drops down permanently right after clicking in Unity input field (it doesn't matter if it is on the same scene or on different one and then you change it to scene with video).

    Unity version: 5.5.1f1
    AVPro version: 1.6.4
    Tested on: Samsung S7 (Android 7.0), Samsung S6 (Android 6.0.1), Samsung S6 Edge (Android 7.0)
    Tested also on IPhone 6 (iOS 10.4) and everything is ok, so probably problem is only on Android platform.

    Reproduction:
    - Add on demo scene (e.g. 08_Demo_360SphereVideo) canvas with input field
    - build on Android platform
    - click on input field -> after that you should see dropping frame rate (it's getting worse with every click)

    Do you have any idea of what may be causing this problem?

    Thanks.
     
  38. lucasTOG

    lucasTOG

    Joined:
    Oct 12, 2016
    Posts:
    7
    Hi, Andrew! Thanks for the response.

    The platform that is having trouble is Android. Specifically, a Samsung Tab 4 (SM-T530). In Unity Editor everything works fine, no error message. The videos are 1280x720. The Unity version is the 5.6.0p2 and the AVPro version is the 1.6.2.

    Seeing that it started after switching to 5.6.0p2 and that this is also happening to @Selaphiel, maybe it is an incompatibility between 5.6.0p2 and AVPro?

    I will upgrade to 1.6.4, try again and let you know.

    Thanks!
     
    Last edited: May 15, 2017
  39. ryaneugenekelley

    ryaneugenekelley

    Joined:
    Jul 8, 2015
    Posts:
    3
    Is anyone having trouble with the new version of Unity? On several projects that work fine (for Android) when I import the package the build fails. I can replicate this on a blank project.

    Note that this is before even using the plugin, it happens simply from import.
     
  40. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Posts:
    2,806
    Which version of Unity is this exactly?
     
  41. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Posts:
    2,806
    Okay, let me know how it goes. We tested with 5.6.0p2 and it works fine. I suspect it it related to the videos you're playing, as in you may be loading too many videos for the device.

    I presume our AVPro Video example/demo scenes work?

    Thanks,
     
  42. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Posts:
    2,806
    It sounds like a bug in Unity. You're using 5.5.1, but 5.5.3 is available and contains many bug fixes - I would try upgrading to that. I will try here and let you know if I also get this issue.

    Thanks,
     
  43. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Posts:
    2,806
    In the Unity 5.5.3 release notes it says:
    • Android: Opening the on-screen keyboard does not make webcam update slower. (827454)
    Which refers to this bug:
    https://issuetracker.unity3d.com/issues/android-inputtext-makes-webcam-update-texture-slow

    So they say it is fixed in 5.5.3 and 5.6.0, but it seems a lot of people are saying its not fixed properly. Maybe you can try to 5.5.3 to see? Anyway, really looks like a bug with Unity as people are getting it with webcam display too.

    Thanks,
     
  44. lucasTOG

    lucasTOG

    Joined:
    Oct 12, 2016
    Posts:
    7
    Upgrading to 1.6.4 didn't solve the problem.
    I don't think that the videos are the problem, because we have been using this plugin for a long time, with the same amount of them. And we don't play more than one at a time.
    I've also tested the sample Demo_Multiple in the device, and it supported 16 videos at the same time -then, crashed.
     
  45. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Posts:
    2,806
    Hmm, I see - interesting...
    Well our basic tests pass on 5.6.0p2, and we've also tested on 5.6.1 - maybe you could try 5.6.1?
    Otherwise, perhaps you could either send your project to us, or describe a reproducible case (using our sample videos, or supply us with videos).
    Thanks,
     
  46. 785130190

    785130190

    Joined:
    May 11, 2017
    Posts:
    21
    You mean I can get one right video frame at every game frame?I use FFmpeg in my last program.I calculate the time and frame myself,and worked perfect!My video has no audio,it's mp4 file enabled CABAC.I'll think of your advices.The crash code will be here tommorrow.
     
  47. jkrumow

    jkrumow

    Joined:
    May 9, 2017
    Posts:
    1
    Hello AndrewRH,

    is there any news regarding progressive streaming? Did you have a chance to test it at least on macOS or Windows?
     
  48. Selaphiel

    Selaphiel

    Joined:
    Jan 31, 2014
    Posts:
    23
    Thanks, I was able to run 2 videos with one as 3840x1920 stereo which was downsampled from 4096 × 2048 and another planar video with 720p resolution.
     
  49. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Posts:
    2,806
    Sorry we haven't made any progress on this yet - we've just been too busy. It's still on the list and we hope to get to it soon. Thanks,
     
  50. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Posts:
    2,806
    Does this mean you solved the problem? What did you change or do to fix it?
    Thanks,