Search Unity

Video Load VideoClip in assetbundle on Android

Discussion in 'Audio & Video' started by VianneyThurotte, Apr 18, 2017.

  1. VianneyThurotte

    VianneyThurotte

    Joined:
    Nov 4, 2016
    Posts:
    4
    Hi,

    I have some problem to get my assetloader work on Android. I try to load VideoClip from assetBundle. It works great on editor but when i try this small piece of code on Android I have this error in my logcat.

    The code :
    Code (CSharp):
    1.        
    2.  
    3.         videos = bundle.LoadAllAssets<VideoClip> ().ToList ();
    4.  
    5.         var go = new GameObject ();
    6.         var player = go.AddComponent<VideoPlayer> ();
    7.         player.renderMode = VideoRenderMode.CameraNearPlane;
    8.         player.targetCamera = Camera.main;
    9.         player.audioOutputMode = VideoAudioOutputMode.Direct;
    10.         player.clip = videos [0];
    11.  
    12.  
    The error :
    Do i need to do some other work to get my videoClip on Android ?

    Thanks in advance for your help

    Blist
     
  2. tiger_wng

    tiger_wng

    Joined:
    Mar 29, 2017
    Posts:
    1
    I got same problem too. Has solved it?
     
  3. BoboShu

    BoboShu

    Joined:
    Nov 20, 2014
    Posts:
    38
    me too !!
     
    SquashSesame likes this.
  4. VianneyThurotte

    VianneyThurotte

    Joined:
    Nov 4, 2016
    Posts:
    4
    Hi,

    I've send an issue to the unity team and this is the anwser :

    Hey,

    Thanks for reporting the issue.

    In https://unity3d.com/jp/unity/whats-new/unity-5.6.0 release notes it says that this feature was not yet implemented. So it is expected behavior to throw an error. As for now, You can simply keep following up with newest unity releases and check if the feature was implemented in newest unity versions.

    Regards,
    Artūras
    QA Team​


    In fact in the 5.6 release note :

    The Android VideoPlayer cannot yet read videos from asset bundles.
     
  5. ymntst

    ymntst

    Joined:
    Jun 9, 2017
    Posts:
    2
    I am sorry to hear that. I have been searching for 2 days.
    is there any other soulution we can use?
    thanks
     
  6. toto007

    toto007

    Joined:
    Jul 18, 2014
    Posts:
    33
    Hi, I read on the video documentation draft that videos are now compatible with assetbundles (look attachment or documentation link).
    Is this feature already confirmed with the current version or will it be scheduled in the next release?
    Schermata 2017-07-10 alle 16.01.13.png
     
  7. ADoby

    ADoby

    Joined:
    Dec 10, 2012
    Posts:
    21
    Any Update on this ?
    I try to load a movie from an assetBundle (The AssetBundle Loader is tried and tested).

    When I try to load a movie I get the reference (I can see the VideoClip in inspector and get its info) but when I try to play it I get following error:
    WindowsVideoMedia error 0xc00d36c3 while reading archive:/CAB-079738cb4484a886591221850bcc2bec/CAB-079738cb4484a886591221850bcc2bec.resource

    Context: MFCreateSourceReaderFromURL
    Error details: Das Schema der angegebenen URL wird nicht unterstützt.
    Track types:

    This is on Windows (Editor and Build)
     
  8. immeasurability

    immeasurability

    Joined:
    Apr 22, 2014
    Posts:
    125
    5.6.2p4 videoplayer from bundle still does not work
     
    Last edited: Aug 14, 2017
  9. immeasurability

    immeasurability

    Joined:
    Apr 22, 2014
    Posts:
    125
    2017.1.0p3 videoplayer from bundle does not work
     
    Last edited: Aug 14, 2017
  10. immeasurability

    immeasurability

    Joined:
    Apr 22, 2014
    Posts:
    125
    5.6.3f1 videoplayer from bundle does not work
     
  11. ercion

    ercion

    Joined:
    Aug 15, 2016
    Posts:
    73
    2017.2.0f3 videoplayer from AssetBundles still not working.
     
    learner_CL, SaphireS and njfed like this.
  12. ChiuGa

    ChiuGa

    Joined:
    Aug 24, 2017
    Posts:
    6
    Does iOS also exist this problem?
     
  13. Desoxi

    Desoxi

    Joined:
    Apr 12, 2015
    Posts:
    195
    Is this still an issue? And if yes is there any workaround?

    EDIT: Does not work on v2017.2.0f3
     
    Last edited: Nov 21, 2017
  14. JeremiBF

    JeremiBF

    Joined:
    Nov 21, 2017
    Posts:
    2
    Ye,same
     
  15. Desoxi

    Desoxi

    Joined:
    Apr 12, 2015
    Posts:
    195
    Tested it on v2017.1.2p3 as well but it still doesnt work.
    Same output:


    AndroidVideoMedia OpenExtractor unable to open archive:/CAB-14baa5416d7d039303ccd3f472c5d1c1/CAB-14baa5416d7d039303ccd3f472c5d1c1.resource, error: 2
    UnityEngine.Video.VideoPlayer:INTERNAL_CALL_Prepare(VideoPlayer)
    UnityEngine.Video.VideoPlayer:prepare() (at /Users/builduser/buildslave/unity/build/artifacts/generated/common/modules/Video/VideoPlayerBindings.gen.cs:175)
     
  16. VianneyThurotte

    VianneyThurotte

    Joined:
    Nov 4, 2016
    Posts:
    4
    • Video: Fixed clip from asset bundle not played. (964652)

      Some things in the patch notes of Unity 2017.2.1
     
  17. TracyWTillis

    TracyWTillis

    Joined:
    Nov 28, 2017
    Posts:
    6
    I hope the Unity team will fix the problem as soon possible since many people are having issue with it.
     
  18. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,311
    Sigh, same issue here, and I'm using 2017.2.1. Video doesn't playback on android.
     
  19. Matt-Jian

    Matt-Jian

    Joined:
    Aug 20, 2012
    Posts:
    2
    the same problem。not fixed in 2017.2.1
    temp load from resources
     
  20. lengykk

    lengykk

    Joined:
    Sep 30, 2017
    Posts:
    1
    I have the same problem too. And finally I found that we can use VideoPlayer's url to resolve this question.Download .mp4 file from remote url and save to persistentDataPath then set the path to VideoPlayer's url.This can work well on Android and IOS both.
     
  21. sanabelapps

    sanabelapps

    Joined:
    Dec 26, 2017
    Posts:
    2
    I thought of an idea, the idea is to save the assets from the assetbundle to the resources folder then loading those assets from resources
     
  22. gamepower7

    gamepower7

    Joined:
    May 16, 2017
    Posts:
    27
    and still in 2017.3
    even if the video is in a sean and the sean is in a asset bundle , same thing
     
  23. delexaet

    delexaet

    Joined:
    Apr 14, 2016
    Posts:
    39
    Confirmed still broken in 2017.3. video/asset bundle issue on android
     
  24. Desoxi

    Desoxi

    Joined:
    Apr 12, 2015
    Posts:
    195
    On the 05.12.17 i received a reply from unity in which they were saying the following:
    "
    ...Video from Assetbundles is not (yet!) supported on Android. : (

    It is on our roadmap though!
    https://unity3d.com/unity/roadmap
    "Video: Android Asset Bundle Support"

    Sorry for the inconvenience, but all I can say is that we are working on it : )"

    I really hope they are working on it to release it in the coming few versions (2018.1 would be great :DD).
    Just wanted to share the information for everyone in here waiting for the "issue" to be resolved.
     
  25. Repzy

    Repzy

    Joined:
    May 20, 2016
    Posts:
    1
    I've downloaded 2018.1 beta and this issue still isn't fixed. Does anyone know if there's a timeline for fixing this?
     
  26. Desoxi

    Desoxi

    Joined:
    Apr 12, 2015
    Posts:
    195
    If you have read the previous post you should know It's not that this seems to be a bug. Its just not supported yet but hopefully is coming in future builds.

    But if you are interested, I have written a workaround for this not using the asset bundle system but a custom system which uses zip archives. If I can find some time I'm going to make my source public and post the link here as well.
     
    JessicaLee88 likes this.
  27. JessicaLee88

    JessicaLee88

    Joined:
    Feb 14, 2018
    Posts:
    13
    Hi Desoxi,

    Would it be possible for you to share the workaround? Thanks so much!
     
  28. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,311
    I read somewhere on these forums (forget now) that it can actually work if you're using uncompressed asset bundles for the videos. I think the compression on the asset bundle is messing up the video codec compression. Not sure though
     
    Mashimaro7 likes this.
  29. JessicaLee88

    JessicaLee88

    Joined:
    Feb 14, 2018
    Posts:
    13
    Thanks so much for the info! Yes! It works fine without compression.
     
    Mashimaro7 likes this.
  30. nicloay

    nicloay

    Joined:
    Jul 11, 2012
    Posts:
    540
    I have similar problem on some devices. Can't reproduce it locally but analytics show that i have about 10% from deaily users reports about this problem.

    Will try to disable compression. Thanks @CDF
     
  31. multimediamarkers

    multimediamarkers

    Joined:
    Feb 17, 2016
    Posts:
    49
    But i have a scene with a videoplayer and a movieclip put all together in 1 assetbundle. Even when i use :

    BuildPipeline.BuildAssetBundles ("Assets/Bundles/Android Bundles", BuildAssetBundleOptions.UncompressedAssetBundle, BuildTarget.Android);

    The movie is not played on Android. On iOS everything worked perfectly. So JessicaLee88 how did you do this?
     
  32. nilsdr

    nilsdr

    Joined:
    Oct 24, 2017
    Posts:
    374
    The difference appears to be in how you store and read from the bundle. In the latest 2018 betas it should work with uncompressed bundles, as long as the bundle is stored locally instead of being read from cache / memory (probably using https://docs.unity3d.com/ScriptReference/AssetBundle.LoadFromFile.html)
     
  33. JessicaLee88

    JessicaLee88

    Joined:
    Feb 14, 2018
    Posts:
    13
    Hey, multimediamarkers,
    Just saw your question. Hope the answer is not too late. The options I was using are as follows: BuildAssetBundleOptions.UncompressedAssetBundle and BuildAssetBundleOptions.ForceRebuildAssetBundle. Also make sure you load the movie locally rather than from cache/memory. That should work with 2018 beta. It will not work with 2017.3.
     
  34. VianneyThurotte

    VianneyThurotte

    Joined:
    Nov 4, 2016
    Posts:
    4
    Something in the last beta update :
    Video: Support for reading videos from AssetBundles on Android.

    Not tested yet.
     
  35. nilsdr

    nilsdr

    Joined:
    Oct 24, 2017
    Posts:
    374
    As posted above, works when reading from local bundle that is not compressed.
     
  36. multimediamarkers

    multimediamarkers

    Joined:
    Feb 17, 2016
    Posts:
    49
    Does anyone has a script example how to load a movie file locally after it is loaded from an AssetBundle on an Android device?
     
  37. nilsdr

    nilsdr

    Joined:
    Oct 24, 2017
    Posts:
    374
    This loads a streamed scene which contains a videoplayer and videoclip (and it works on android).

    If you want to load the clip itself from a bundle instead of include it in a scene, just load it from bundleFile after LoadFromFile and assign it to the clip property of the VideoPlayer component.

    Code (CSharp):
    1. string filePath = Path.Combine(Application.persistentDataPath, "videoplayer");
    2.  
    3.                 DownloadHandlerFile dh = new DownloadHandlerFile(filePath);
    4.  
    5.                 UnityWebRequest requestFile = UnityWebRequest.Get(url);
    6.  
    7.                 requestFile.downloadHandler = dh;
    8.  
    9.                 yield return requestFile.SendWebRequest();
    10.  
    11.                 if(!requestFile.isHttpError && !requestFile.isNetworkError)
    12.                 {
    13.                     Debug.Log("Download complete, attempting to load bundle.");                
    14.  
    15.                     AssetBundle bundleFile = AssetBundle.LoadFromFile(filePath);
    16.  
    17.                     SceneManager.LoadScene(bundleFile.GetAllScenePaths()[0]);
    18.                 }
    19.                 else
    20.                 {
    21.                     Debug.LogError(requestFile.responseCode + ": " + requestFile.error);
    22.                 }
     
    moderebel and ebonywidow like this.
  38. DOT-GROUP

    DOT-GROUP

    Joined:
    Nov 28, 2016
    Posts:
    3
    Unity 2018.1.0f2 and can't play clip from bundle in Android. Will try saving video to persistentDataPath
     
    SeonSoh likes this.
  39. prasetion

    prasetion

    Joined:
    Apr 3, 2014
    Posts:
    28
    @JessicaLee88 hai jessi, i have similiar problem when load video in assetbundle, may i know your unity version when load video as assetbundle?. I have been tried in 2018.1 and compiled to android, and still not working. And when i try to download seperate file video only to persistentDatapath, it does not work too. But in editor works fine. Today i will try to uncompress the assetbundle, and post the result. ohh, by the way, i used Assetbundle browser to handle assetbundle, it makes me easy to manage assetbundle. Thanks before
     
  40. nilsdr

    nilsdr

    Joined:
    Oct 24, 2017
    Posts:
    374
    JessicaLee88 likes this.
  41. JessicaLee88

    JessicaLee88

    Joined:
    Feb 14, 2018
    Posts:
    13
    Hey, Prasetion, I am using the latest 2018.1.0f2 release with uncompressed asset bundle. Videos load very smoothly. It won't work with any previous versions of Unity.
     
  42. JessicaLee88

    JessicaLee88

    Joined:
    Feb 14, 2018
    Posts:
    13
  43. kognito1

    kognito1

    Joined:
    Apr 7, 2015
    Posts:
    331
    Same problem/error on webgl too (using 2018.1.4f1)!
     
  44. ebonywidow

    ebonywidow

    Joined:
    Feb 18, 2015
    Posts:
    2
    Hi nilsdr,

    Thank you very much for sharing your code. Unity has been going through a lot of changes recently with regards to assetBundles and I am struggling to find/implement up to date code that will not be deprecated within the near future, regarding assetBundles as I try to implement it in my code. I was wondering if you might have a sample of your above code using assetBundles along with the hash/caching system?

    Thanks in advance! :)
     
  45. NewYorkHOK

    NewYorkHOK

    Joined:
    Oct 13, 2017
    Posts:
    5
    How do you use both of those settings? it only takes that argument once
     
  46. NewYorkHOK

    NewYorkHOK

    Joined:
    Oct 13, 2017
    Posts:
    5
    This is still an issue for me in Unity 2018.2.5f1.

    Has anyone found a solution? I should be able to just download the assetbundle with the video, assign it, prepare it and play it, but it wont play. :(

    Any help is really appreciated!! :)
     
  47. augivision

    augivision

    Joined:
    Mar 27, 2018
    Posts:
    14
    I am doing a Vuforia Augmented Reality app and I am using a video with a green screen. I use a Chroma Key tool from the Asset Store to key out the background.

    Everything works perfectly in the editor and on my android -- HOWEVER, when I try to download and load it from an asset bundle it does not work.

    It think I should be able to download videos from an asset bundle. Seems like a basic feature that everyone should be able to use. If it is not working or available, it should be fixed asap. Please!
     
  48. FlashyGoblin

    FlashyGoblin

    Joined:
    Apr 1, 2017
    Posts:
    23
    Does anyone know if this is fixed yet? Loading videos from asset bundles is really a must have.
     
  49. Viewzoom

    Viewzoom

    Joined:
    Jan 16, 2016
    Posts:
    7
    Let me end this issue.
    Firstly, thanks for all the answers above. After my try and try and try. I finally found the solution.
    To make VideoPlayer that packed into an AssetBundle works fine on Android platform, there are two key points you have to take care.

    First, use BuildAssetBundleOptions.UncompressedAssetBundle to build your AssetBundles.

    BuildAssetBundleOptions options = BuildAssetBundleOptions.None;
    if (target == BuildTarget.Android)
    {
    options = BuildAssetBundleOptions.UncompressedAssetBundle;
    }
    else if (target == BuildTarget.iOS)
    {
    options = BuildAssetBundleOptions.None;
    }
    BuildPipeline.BuildAssetBundles(outputFolder, builds, options, target);

    Second, use AssetBundle.LoadFromFile() to load your AssetBundle instead of using WWW.

    string path = Application.persistentDataPath + "/" + assetBundleName;

    AssetBundle bundle = AssetBundle.LoadFromFile(path);

    GameObject prefab = bundle.LoadAsset<GameObject>(assetName.ToLower());

    That's all. On iOS platform, you can still use WWW to load your AssetBundle.

    By the way, the Unity Editor version I use is 2018.2.12f1.

    Finally please allow me to introduce my personal Unity Project - Racing Liberty. It's a 3D mobile racing game. You can download it on Google Play Store now. The iOS version is under reviewing and will coming soon. Have a try.
     
    ridoneakash5 likes this.
  50. UweR7

    UweR7

    Joined:
    Jul 27, 2017
    Posts:
    20
    Please do not get me wrong!
    Your solutions seems to be the first candidate that could really work!
    Believe me, I did also a lot of testing and trying - and found no for me working solution.
    So thank you for your effort and the fact that you are sharing your findings!!!

    On the other side:
    Not using
    using (var www = WWW.LoadFromCacheOrDownload(url, ...)) { ... }

    means loosing all caching benefits.

    "...LoadFromFiles(...)" is a blocking operation. Ok we can use "LoadFromFileAsync(...)" to solve this ...

    But the unity docu says that both methods are requiring a "Path of the file on disk."
    This means that the asset bundles must be copied first "somehow" to the mobile device.
    My goal is that they are stored on a public web server; keywords: Maintenance, changing content (=asset bundles) while the app (=apk in this case) must not be changed ...

    Seems finally that we have to wait until Unity is fixing this!
    Or do I miss something?

    But as said:
    Thxs 4 u effort and sharing! Great work!!