Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Mobile Movie Texture

Discussion in 'Assets and Asset Store' started by DanTreble, Dec 17, 2011.

  1. GyeongNamStyle

    GyeongNamStyle

    Joined:
    Oct 28, 2012
    Posts:
    2
    Dan, plz reupload 1.1.5 ver. t.t
     
  2. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    Best username ever, last month!

    Will upload 1.1.6 tomorrow, just want to double check shaders work on Adreno 205 devices as there were rumours of pink earlier in the thread. Thanks
     
  3. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    1.1.6 Uploaded and live.
     
  4. MatthewLeeFarmer

    MatthewLeeFarmer

    Joined:
    Jul 31, 2012
    Posts:
    14
    I've updated to 1.1.6, but the shader updates have caused the movies to no longer appear in a RenderTexture. Is there anything I can change to get this to work? Let me know if you need any further details.

    Thank you!
     
  5. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    At the very least can you tell me what platform? Editor Windows/OSX/iOS/Android/All?
     
  6. MatthewLeeFarmer

    MatthewLeeFarmer

    Joined:
    Jul 31, 2012
    Posts:
    14
    Certainly! We're using iOS editor and iOS devices.
     
  7. johnnysky

    johnnysky

    Joined:
    Nov 7, 2012
    Posts:
    1
    Hello DDTOM, Why I posted to the iPad cannot play the video? Only one color plane.thanks.
     
  8. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,027
    When trying to build to android:

    Code (csharp):
    1. Assets/MobileMovieTexture/MobileMovieTexture.cs(249,21): error CS0117: `AssetStream' does not contain a definition for `GetFileOffsetLength'
    2.  
    3. Assets/MobileMovieTexture/MobileMovieTexture.cs(259,50): error CS0117: `AssetStream' does not contain a definition for `GetApkPath'
    4.  
    5. Assets/MobileMovieTexture/MobileMovieTexture.cs(259,69): error CS0165: Use of unassigned local variable `offset'
    6.  
    7. Assets/MobileMovieTexture/MobileMovieTexture.cs(259,82): error CS0165: Use of unassigned local variable `length'
    8.  
    9. Assets/MobileMovieTexture/MobileMovieTexture.cs(259,27): error CS1502: The best overloaded method match for `MobileMovieTexture.OpenStream(string, int, int, bool, bool)' has some invalid arguments
    10.  
    11. Assets/MobileMovieTexture/MobileMovieTexture.cs(259,27): error CS1503: Argument `#1' cannot convert `object' expression to type `string'
    12.  
    13.  
    14.  
    tips?

    edit: reimporting the plugin seems to have fixed it
     
    Last edited: Nov 14, 2012
  9. Mtp

    Mtp

    Joined:
    Nov 15, 2012
    Posts:
    1
    Hello,

    is there a way to TRY OUT the YCrCbtoRGBSplitAlpha.Shader with a demo version of Mobile Movie Texture?

    I am only trying to make a Transparent Movie with texture for IOS.
     
  10. floky

    floky

    Joined:
    Oct 6, 2010
    Posts:
    273
    Hey Dan,

    We bought a license for your plugin a few months ago. We had some problems accessing a video on Android that is located in a separate apk file.
    We then updated to the latest release where you say you've added support for OBB streaming. We've been having other problems with that too:
    Building your sample scene unity project for android into a split apk works perfectly. It finds the video inside the external apk file of the project and plays it.

    When we used the plugin in a much larger unity project also built by splitting the apk into an installer and a gameData.apk file, the plugin fails to play the video file although it finds it in the external gameData.apk.

    After a lot of digging I've found what was causing the crash. The movie picture size returned (width and height) were 0. I also noticed that the calculated offset of the video you get from your ZipHelper.jar plugin is wrong and because of that it doesn't read the video correctly. I then decompiled the ZipHelper.jar (sorry for that I didn't have any faster solution) and found that my suspicions were correct: the way you calculate the offset of files inside the APK is not correct.

    The main reason for that is the way the ZIP (aka APK) file is packaged. For smaller apk files you can easily get lucky and files get packed in a order where the way you calculate the offset gives the correct file offset, because all compressed files are at the end of the apk file. But for larger apk files with various types of resources, they will be packed in a mixed order where some of them are compressed, some of them aren't (videos and other resources are usually not compressed). Thus the offset of the targeted video in a such APK must take into account different constant offsets depending on the next ZIP entry file type and compression. You are using the same constant offset for all the APK entries something like this: offset += 30 + entry.getName().length() + extra.
    But this won't be correct in all possible situations the entry files are stored in a ZIP.

    For a more correct way to support OBB and other APK streaming solution I suggest you replace your ZipHelper.jar file with the ZipResourceFile.java class
    provided by Google to be used as support for OBB files. You can find this if you install the "Google Play APK Expansion Library" from the Android SDK Manager and then you should find the class mentioned in "<sdk>/extras/google/google_market_apk_expansion/zip_file/" like it's mentioned in the documentation: http://developer.android.com/guide/google/play/expansion-files.html#ZipLib

    You will find in the link above how you can get a "AssetFileDescriptor" from the APK file by using that class and from the descriptor you can get the correct file offset and length.

    Hope this helps!

    Looking forward for the new version of MobileMovieTexture library my friend! You've done a great job with it!
    PM me if you need any more details or any help regarding the above mentioned issue mate.
     
    Last edited: Nov 21, 2012
  11. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    Wow flocky, great detective work. When I found that zip offset code on stackoverflow, there was a comment saying it might be dangerous, but it seemed to work in all my tests!

    Downloading <sdk>/extras/google/google_market_apk_expansion now to take a look at it, hopefully it should be pretty easy to use :)

    Thank you!
     
  12. floky

    floky

    Joined:
    Oct 6, 2010
    Posts:
    273
    No problem my friend! Glad to help!
    Yes it should be straightforward to use the ZipResourceFile class directly and call it's methods from your AssetStream.cs class.
    I'm gonna try it today to see if it works as expected and I will keep you up to date.
     
  13. Hiroty

    Hiroty

    Joined:
    Nov 22, 2012
    Posts:
    4
    I used the demo version.

    Since "We would like to use movie texture." "Can't movie texture be used?" "Why ...

    was said to the boss almost every day,
    It was very helpful. Thank you!



    When I would like to load from Application.persistentDataPath or temporaryCachePath,
    Should this be changed?



    m_nativeContext = OpenStreamDemo(AssetStream.GetApkPath(), (int)offset, (int)length, m_loop, pot );
    #elif UNITY_IPHONE !UNITY_EDITOR
    m_nativeContext = OpenStreamDemo(Application.dataPath + "/Raw/"+ m_path, 0, 0, m_loop, false);
    #else
    m_nativeContext = OpenStreamDemo(Application.dataPath + "/StreamingAssets/" + m_path, 0, 0, m_loop, true);
    #endif


    And...

    Can network streaming be supported?
     
  14. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    Hi,

    I tried using the demo in my scene on andriod, it works fine. Then I bought the package 1.1.6, and it is pink on device (in editor, it is fine).
     
  15. floky

    floky

    Joined:
    Oct 6, 2010
    Posts:
    273
    Hey there Dan!

    Just wanted to confirm that using Google's ZipResourceFile.java class in your AssetStream.cs works like a charm.

    I posted you the modified AssetStream.cs so you can include it in your next version of the plugin.
    Here are both the files:
    View attachment $AssetStream.cs
    View attachment $ZipResourceFile.zip

    Hope this helps.
     
    Last edited: Nov 23, 2012
  16. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    Saved me all the work, too kind flocky, thank you!

    Update submitted
     
  17. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    Yeah, change that. You can put any path on the file system in there and it should work. On the other side, it does a fopen.

    No immediate plans. Sorry :-(
     
  18. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    Hey imtrobin, thanks for buying it.

    Can you try reimporting the paid version again please? Sounds like a mismatch between paid/free
     
  19. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    Your sample works fine but in my scene I get an error when deployed on the phone.

    texture has out of range widht / height
    >> UnityException: Failed to create texture because of invalid parameters

    It works fine in editor.

    I tried on another phone. I don't get the above error but I get a null error exception.
     
    Last edited: Nov 25, 2012
  20. floky

    floky

    Joined:
    Oct 6, 2010
    Posts:
    273
    That's the error that I was getting with the version 1.1.6 of the MobileMovieTexture library, but then I applied the fix I mentioned above and had no other issues so far.
    Dan said that he will soon launch an update to fix this issue.
     
    Last edited: Nov 25, 2012
  21. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
  22. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    It sort of works. I get an error in the log when deploying on android

    JNI: Init'd AndroidJAvaObject with null ptr!

    >> Couldn't find file: assets/MovieSasmples/myfile.ogv

    It plays a video but Instead it is playing the default explosion movie instead of my video. In editor, it is playing my video fine.
     
  23. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    Very sorry, I missed a file with the delta. Try this View attachment $1.1.7 delta.2.unitypackage , or wait for the actual asset store update to go through :-/
     
  24. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    ok, this works.
     
  25. Muckel

    Muckel

    Joined:
    Mar 26, 2009
    Posts:
    470
    Hello,
    well i have a problem. I now need to check Autoplay to get the Video load... But if i start my App all Video's are load and play back automatic and that takes a lot of power... so what can i do to get the first frame from Video load so that the Camera can see the Image and not a Green Screen... ??
    Now i have to use "Play Automatic" because if i don't than the Camera see's no image just a Green Screen...

    thank you!
     
  26. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    actually I think I spoke too soon. I put it in svn, then update again, and it fails. It seems unity deleted some of the files or something or maybe it converted to text mode and it fails. I need to reimport the package to get it to work.
     
  27. DanielTortosa

    DanielTortosa

    Joined:
    Jul 25, 2012
    Posts:
    5
    To avoid pink/green and adjust to real screen resolution (Full screen) i do this (in Unity4):

    Code (csharp):
    1.  
    2.  
    3. private static MobileMovieTexture MovieTextureScript = null;
    4. private static Material _movieTextureMaterial;
    5.        
    6. void Awake ()
    7. {
    8.    MovieTextureScript = GameObject.Find ("Main Camera").GetComponent<MobileMovieTexture> ();
    9. _movieTextureMaterial = new Material (Resources.Load ("Shaders/YCrCbtoRGB") as Shader);
    10. //Need to modify original MobileMovieTexture File to allow assign a material.
    11. MovieTextureScript.MovieMaterial = _movieTextureMaterial;
    12. vertice1 = new Vector3 (0, Screen.height, 0);
    13. vertice2 = new Vector3 (Screen.width, Screen.height, 0);
    14. vertice3 = new Vector3 (Screen.width, 0, 0);
    15. vertice4 = new Vector3 (0, 0, 0);  
    16. }
    17.        
    18.     void OnPostRender ()
    19.     {
    20.         GL.PushMatrix ();
    21.         _movieTextureMaterial.SetPass (0);
    22.         GL.LoadPixelMatrix ();
    23.         GL.Begin (GL.QUADS);
    24.         GL.TexCoord2 (0, 1);
    25.         GL.Vertex (vertice1);
    26.         GL.TexCoord2 (1, 1);
    27.         GL.Vertex (vertice2);
    28.         GL.TexCoord2 (1, 0);
    29.         GL.Vertex (vertice3);
    30.         GL.TexCoord2 (0, 0);
    31.         GL.Vertex (vertice4);  
    32.         GL.End ();
    33.         GL.PopMatrix ();
    34.     }
     
  28. Muckel

    Muckel

    Joined:
    Mar 26, 2009
    Posts:
    470
    perfect!
    many thx for sharing!!!
     
  29. Hiroty

    Hiroty

    Joined:
    Nov 22, 2012
    Posts:
    4
    We are using Unity3.5.2,

    If it is going to buy MobileMovieTexture,
    it is displayed as "Needs Unity upgrade to version 3.5.6",
    and we cannot buy.

    By the situation of a project in the company, upgrade is difficult.

    Would you enable it to perform by Unity3.5.2?
     
  30. dev_peter

    dev_peter

    Joined:
    Aug 9, 2012
    Posts:
    38
    A quick question about converting. In the unity manual it says (http://docs.unity3d.com/Documentation/Manual/VideoFiles.html):
    "When a video file is added to your Project, it will automatically be imported and converted to Ogg Theora format."

    So is there a way I can use this video? Inside the streaming folder there is still only an mp4 when I import the file. It would save some time converting the videos.
     
  31. timsk

    timsk

    Joined:
    May 27, 2011
    Posts:
    177
    Has anyone found a way to build a bundle containing video files to a mobile device?

    We don't want the videos bloating the app size. So we would like to build them to a bundle, then download them over the web at runtime.

    I'm assuming there is a way to do this as a couple of people have mentioned using this plugin with asset bundles.
     
  32. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    Hi,
    I'm evaluating this for an eLearning project and have a couple of questions (having read through the forum I'm still a little confused about features)

    Does this support video clips with audio?
    Can you change movies?

    I've got the demo 1.1.1 package and Unity4 pro but the documentation is minimal.

    ty!
     
  33. floky

    floky

    Joined:
    Oct 6, 2010
    Posts:
    273
  34. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
  35. blaize

    blaize

    Joined:
    Jul 25, 2012
    Posts:
    41
    Wouldnt it be possible to add an external audio source?
    When the video starts playing, it would also starts an mp3 file. this would work the same for the pauze button
     
  36. Muckel

    Muckel

    Joined:
    Mar 26, 2009
    Posts:
    470
    Hello,

    how can i make the variable public :
    [UnityEngine.SerializeField]
    private Material m_movieMaterial;

    plz can someone post a example ? thank you

    another question is there a Demo how to play more than 1 Video file like a Videoplayer with playlist ?

    many thxxx
    here is my Script for Playback i use... maybe it is handy for someone...
    Code (csharp):
    1. #pragma strict
    2.  
    3. var m_movieTexture : MobileMovieTexture;
    4. private var _movieTextureMaterial : Material = null;
    5. private var plane : GameObject;
    6. var videoWidth : float;
    7. var videoHeight : float;
    8. var AspectRatio : float;
    9. var LossyScale : Vector3;
    10. var m_loop : boolean = false;
    11.  
    12. function Awake (){
    13.     _movieTextureMaterial = m_movieTexture.MovieMaterial;
    14.     plane = gameObject;
    15.     if (m_movieTexture != null)
    16.     {
    17.             m_movieTexture.playAutomatically = false;
    18.             //m_movieTexture.m_loop = LoopVideo;
    19.             m_movieTexture.onFinished += OnFinished;
    20.             m_movieTexture.Play(); //Prewarm
    21.             m_movieTexture.pause = true;
    22.      }
    23. }
    24.  
    25. function Start () {
    26. AspectRatio = m_movieTexture.aspectRatio;
    27. videoWidth = (m_movieTexture.width * 0.1);
    28. videoHeight = (m_movieTexture.height* 0.1);    
    29. plane.transform.localScale = Vector3(videoWidth, 1.0, videoHeight);
    30. LossyScale = transform.lossyScale;
    31. PlayVideo ();
    32. }
    33.  
    34. function PlayVideo () {
    35.     yield WaitForSeconds (0.5);
    36.     if (m_movieTexture != null)
    37.     {
    38.     m_movieTexture.Play();
    39.     }
    40. }
    41. function PauseVideo () {
    42.         if (m_movieTexture != null)
    43.         {
    44.             m_movieTexture.pause = true;
    45.         }  
    46. }
    47. function OnFinished(sender : MobileMovieTexture)
    48.     {
    49.         //Debug.Log(sender.Path + " has finished ");
    50.         if (m_loop == true)
    51.         {
    52.             if (m_movieTexture != null)
    53.             {
    54.                 m_movieTexture.Play();
    55.             }
    56.         }
    57.     }
    58. function OnDestroy() {
    59.        if (m_movieTexture != null)
    60.         {
    61.             m_movieTexture.onFinished -= OnFinished;
    62.         }
    63. }
     
    Last edited: Dec 8, 2012
  37. DanielTortosa

    DanielTortosa

    Joined:
    Jul 25, 2012
    Posts:
    5
    Not sure if you are looking for this (inside MobileMovieTexture.cs - lin 113):

    public Material MovieMaterial
    {
    get { return m_movieMaterial; }

    //<<added>>
    set { m_movieMaterial = value;}
    //<<added>>

    }
     
  38. Muckel

    Muckel

    Joined:
    Mar 26, 2009
    Posts:
    470
    perfect!
    thank you

    Well i still have a pink line @ the bottom of the Video ... just 1 pixel...hmmm
    Can you maybe explain what you do with the Vertices in your Code ?
    Attached is a image that shows the Pink line under the Video.
    If i watch the Video in VLC all is fine ... no Pink line...
    it only shows up in fullscreen Videos also in the Editor ...
    What does OnPostRender() do in this case ?
    many thxx for help!
     

    Attached Files:

    Last edited: Dec 11, 2012
  39. dducrest

    dducrest

    Joined:
    May 2, 2012
    Posts:
    10
    I have a few humble suggestions. I have setup my project to load your program programmatically and I have to make a few changes to your MobileMovieTexture.cs everytime I want the latest update.

     
  40. dukester

    dukester

    Joined:
    Nov 7, 2012
    Posts:
    14
    Just bought it.
    Great piece of software.
    Mobiles aside, you should get it even for Standalone. Solved some nasty issues for me.

    Wishlist:
    - audio support
    - Seek( ), or at least Rewind( )
    - +1 vote for completing the get/set for important properties in MobileMovieTexture.cs
     
  41. misc

    misc

    Joined:
    Jul 11, 2012
    Posts:
    8
    Is there a way to make it run on the web player with offline deployment?
     
    Last edited: Dec 21, 2012
  42. kakalot

    kakalot

    Joined:
    Dec 27, 2012
    Posts:
    1
    Video playback of multiple mobile movie texture reminds error.
    Of course, the PC does not an error. Android, Apple Mobile
    Error has a serious problem. Flies fast being done after confirmation please.

    A series of videos during playback
    v1.1.4 No error
    v1.1.6 error

    ps I am Korean and google translator to translate.
     
  43. Deleted User

    Deleted User

    Guest

    Hi,

    I bought your plugin and it works great.

    But I have couple of videos that have the alpha video combined at the top of the normal video. Basically it's the other way around to 'ExplosionSplitAlpha' video that comes with the import. How can I change the 'YCrCbtoRGBSplitAlpha' shader to make my videos work with the split alpha shader you have.

    Many Thanks in advance.
     
  44. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    Sadly not. Web players can't run native code. The built in Unity MovieTexture should work in the web player though...
     
  45. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    What is the error message kakalot?
     
  46. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    Attached version is swapped, I _think_.

    View attachment $YCrCbtoRGBSplitAlpha.shader

    Is this a standard at all? What program made them? I'll happily flip my default if it is more standard :)
     
  47. Defero

    Defero

    Joined:
    Jul 9, 2012
    Posts:
    200
    Hi dan
    i sent you a pm
     
    Last edited: Jan 4, 2013
  48. Deleted User

    Deleted User

    Guest

    Hay DanTreble,

    Thanks for the quick reply,

    I tried your changed shader it works but not fully. What I mean by that is that it shows the video with split alpha correctly. With the correct alpha values and such, but the colours have disappeared from the video. basically it displays a grayscale video with alpha even though the video that I have has colour in it.

    I did how ever managed to get this thing working last night but didn't get around to posting my findings here. I commented out the bottom part of your shader (the optimised version so to speak), and uncommented the top part. And swapped 'texcoordBottom' and 'texcoordTop' on lines 52-54. This did the trick. I now have a split alpha shader that displays colours correctly.

    here is the edited shader View attachment $YCrCbtoRGBSplitAlpha.shader . This may be not the most optimised version but it works. Could you give me some pointers on how to solve the colour not showing up in your optimised version of the shader you previously posted. I don't have that much knowledge in shader programming by the way. :)

    I have no idea if this is the standard or not. I was using a prime 31 plugin for another app that I was doing for iOS and since they didn't have a split alpha solution, I wrote my own shader to do the splitting. And this is how I placed the alpha channel on my videos (alpha video on top, normal video on bottom). Still don't know which is the standard. So don't bother with changing your code I guess. :)
     
  49. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    Oh dear, I did do it blind!

    It isn't really optimised, it is just expanded and hacked to work around a bug with cg compiler on directx and mac open gl. http://fogbugz.unity3d.com/default.asp?435499_gmci3gfh1fe6mrmo

    Awesome, that is exactly the change I tried to make in the expanded version.


    Aras gave me a way to workaround the bugs in Unity 4.0 which means I don't need the expanded version in there. If you are using 4.0, try this View attachment $YCrCbtoRGBSplitAlpha.shader version (and swap bottom and top again)
     
  50. Deleted User

    Deleted User

    Guest

    Hi,

    Well, if thats the case I would use the version that I have at the moment since I'm using Unity 3.5, but will use the new version of your's in later projects. And since I'm deploying this solely on android, this 'cg compiler' issue wouldn't be an issue for me right?

    So far I've tested the app on an old Galaxy tab 10.1 and a Galaxy SII. Both work pretty well.

    Thanks again for your amazing support.