Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Mobile Movie Texture

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

  1. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    Full Version
    Demo Version (Same api. Works on all platforms, Windows/OSX/iOS/Android, but watermarks the decoded video)

    Play ogg theora encoded videos on a texture in your iPhone/iPad/Android projects.

    Changes

    Version 2.1.2 15/04/2015
    • iOS/Android: Fix Unity 5.0 support
    • iOS: Add metal support
    • Win: Fix split alpha on DX11
    • All platforms: fix playing movies of different dimensions sequentially on same MMT component

    Version 2.1.1 27/01/2015
    • All platforms: Fix a crash

    Version 2.1.0 20/01/2015
    • All platforms: 64 bit support
    • iOS/Android: Multi threaded rendering support >= Unity 4.5
    • Android: x86 support
    • Win: Direct X 11 support
    • Win: OpenGL support
    • Win: Native threading, remove dependency on pthreads
    • iOS: Use more arm assembly
    • All platforms: Improved movie picker
    • All platforms: Fixed threading model, eliminated a deadlock
    • All platforms: Fixed problem with the manager not cleaning itself up
    • All platforms: Fixed the TextureContext comparison
    • All platforms: Made the naming a little more consistent

    Version 2.0.4 01/05/2014
    • iOS/Android: Fix 'green textures' problem.

    Version 2.0.3 21/04/2014
    • All platforms: Fix stop not working properly
    • All platforms: Fix intermittent starting bug
    • Win: DLL is now compiled with Visual Studio 2010 ( was 2008 )

    Version 2.0.2 26/03/2014
    • All platforms: Fix black flash between consecutively played (same size) movies on MMT object
    • Android: Fix scan duration

    Version 2.0.1 24/03/2014
    • All platforms: Bring back the finished flag

    Version 2.0.0 15/03/2014
    • All platforms: Add video seeking (now built on top of liboggz, thanks Andy Suter).
    • All platforms: Each video decodes on its own thread.
    • Win/OSX: Move to unity's native render plugin system (no DX11 or Win 64 bit yet).
    • All platforms: Can now scan the duration of a movie.?
    • All platforms: Playback speed exposed and better looping options
    • All platforms: Simplified the shaders
    • All platforms: Load from absolute path
    • All platforms: Removed the external chroma key material editor, use material property drawers now
    • All platforms: Moved all code into the MMT namespace
    • iOS: Removed XCode 3 support.
    • All platforms: Split alpha has a horizontal option in the shader
     

    Attached Files:

    Last edited: May 17, 2015
  2. rdombrowski

    rdombrowski

    Joined:
    Nov 16, 2011
    Posts:
    1
    the posted url is a 404...any updates?
     
  3. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    My bad, url has been updated.

    Still no videos yet, been hard at work on some additional iOS optimisations.
     
  4. pixelsteam

    pixelsteam

    Joined:
    May 1, 2009
    Posts:
    924
    Looking forward to seeing the video.
     
  5. runonthespot

    runonthespot

    Joined:
    Sep 29, 2010
    Posts:
    305
    Sounds amazing- would love to see a video of this running on the device- what we can expect with start times etc, and if we can cue to places in the video.
     
  6. DDTOM

    DDTOM

    Joined:
    Dec 26, 2011
    Posts:
    3
    Hi.

    I bought "Mobile Movie Texture" with Asset Store of Unity.

    On the editor(MacOS10.7), the sample operated good.
    However, if the Xcode project of iOS is outputted and performed, the following errors will come out and stop.

    >Exception: problem opening movie
    > at MobileMovieTexture.Open () [0x00000] in <filename unknown>:0
    > at MobileMovieTexture.Play () [0x00000] in <filename unknown>:0
    > at MobileMovieTexture.Start () [0x00000] in <filename unknown>:0

    Plugins and StreamingAssets are moved as instructions.txt.

    The following codes are added to "MobileMobieTextures.cs" and it is checking that surely an ogg file exists on iPhone.

    > if (File.Exists(Application.dataPath + "/Raw/"+ m_path))
    > {
    > Debug.Log( " ogg Exist!!!!!!" );
    > }
    > else
    > {
    > Debug.Log( " ogg not Exist!!!!!!" );
    > }


    It also worries that the following warning is outputted in large quantities also at the time of a link.

    >Unexpected srelocation type 9

    The version of Unity currently used and Xcode is as follows.

    Unity3.4.2
    Xcode3.2.4
    (Although tried also on Xcode4.2, it did not pass even along build. )

    Since it is troubled very much, please help me.
     
  7. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    Hey DDTOM, thank you for buying it. I'm very sorry you are having trouble.

    Does my sample scene work for you on iOS?

    Can you send me the video that is causing you problems?
     
  8. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    Hopefully you can check out the demo. No cueing supported yet. Next up I need to support frame dropping, it slows the video down to keep it in sync, but it wont frame skip if the video is decoding too slowly. Then I'll look at cueing.
     
  9. DDTOM

    DDTOM

    Joined:
    Dec 26, 2011
    Posts:
    3
    Thank you for response.

    Unfortunately I tested your sample scene on iOS.
    However,that didnt work.

    Can you tell me your environment - Unity or XCode.

    And I update ver1.1, but it doesnt work after all on Unity Editor or iOS.
    (only black plane on Game window,and iOS is same errors.)
    What did you do?
     
  10. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    I'm using Unity Pro 3.4.2f2 and XCode 4.2 Build 4C199 on Mac OSX 10.6.8

    Let me send you a full working project. I will pm you one now.
     
  11. DDTOM

    DDTOM

    Joined:
    Dec 26, 2011
    Posts:
    3
  12. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    Managed to get it compiling, check you private messages for a link.
     
    Last edited: Dec 28, 2011
  13. Swearsoft

    Swearsoft

    Joined:
    Mar 19, 2009
    Posts:
    1,632
    Difference between Free and Full?
     
  14. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    Free watermarks each keyframe with the word "DEMO".
     
    JPLKit likes this.
  15. Swearsoft

    Swearsoft

    Joined:
    Mar 19, 2009
    Posts:
    1,632
    ah, so I can test functionality on the device, which is what I wanted. Great! Thanks for the reply (maybe add it to the OP)
     
  16. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    I'll do that now, thanks for the interest.
     
  17. Swearsoft

    Swearsoft

    Joined:
    Mar 19, 2009
    Posts:
    1,632
  18. appleunited

    appleunited

    Joined:
    Dec 25, 2010
    Posts:
    103
    Is it supposed to work on editor as well? I did not see the movie playing.
     
  19. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    It is.

    I've tested Unity Pro 3.4.2f2 on Mac OSX 10.6.8 and Unity Pro 3.4.2f2 on Windows 7 64bit. However there is no 64 bit code in the dll/bundle.

    What are you running?
     
  20. appleunited

    appleunited

    Joined:
    Dec 25, 2010
    Posts:
    103
    I am using Unity Pro 3.4.2f2 on Mac OSX 10.6.8 as well. All I see is the button "Pause" and a black screen. Any advise on how I should debug this? I downloaded the demo package from the Asset Store.
     
  21. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    Quick sanity check, but did you move the Plugins directory and the StreamingAssets directory to the root Assets directory?

    Sadly the Asset store wont let me ship with them in the correct place.
     
  22. appleunited

    appleunited

    Joined:
    Dec 25, 2010
    Posts:
    103
    Yes, I did. Read the instruction.txt that comes with the bundle. :)
     
  23. appleunited

    appleunited

    Joined:
    Dec 25, 2010
    Posts:
    103
    I managed to get it to work in a brand new unity project but it doesn't work when I import the package to an existing project. Any idea what could be wrong?
     
  24. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    That's tough... any console logs? While it is playing can you inspect the material and see it is the correct shader and has 3 textures on it with the movie playing in it?
     
  25. appleunited

    appleunited

    Joined:
    Dec 25, 2010
    Posts:
    103
    Found out what is the issue. It is the architecture setting. In my existing project, I have set to armv6 because I need to have it run in older generation of iPod. Could you make your library file compatible with armv6?
     
  26. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    That's a little tricky. I don't think it would be fast enough on armv6. I can't use shaders to do the color space conversion on armv6 and I don't think I can use neon instructions either. I was led to believe that 3g represented a slither of the devices.
     
  27. appleunited

    appleunited

    Joined:
    Dec 25, 2010
    Posts:
    103
    That is a pity because that would be a perfect tool to do cut scene in my game.
     
  28. rogeliopuig

    rogeliopuig

    Joined:
    Dec 29, 2011
    Posts:
    13
    While I was using version 1.0 of mobile movie texture in conjunction with metaio mobile sdk, everything was working fine, i could have a plane with a texture from camera feed and another with a video. Since the 1.1 version has been release, the texture with the video mixes with the one from the camera feed. When I run the scene with just one of them, the colour looks ok. Any idea? Find in the attachment, a sample of what happens
     

    Attached Files:

  29. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    Phew, think I have found a fix. Sorry for the trouble.

    Would you try adding a
    Code (csharp):
    1. GL.InvalidateState();
    Directly after the call to

    Code (csharp):
    1. DecodeAndUpload(m_nativeContext...
    If that works for you, I'll submit the fix.

    Thanks!
     
    Last edited: Dec 30, 2011
  30. rogeliopuig

    rogeliopuig

    Joined:
    Dec 29, 2011
    Posts:
    13
    the code looks like this
    Code (csharp):
    1.  
    2. #if (UNITY_ANDROID || UNITY_IPHONE)  !UNITY_EDITOR
    3.     DecodeAndUpload (m_nativeContext, m_ChannelTextures[0].tex.GetNativeTextureID (), m_ChannelTextures[1].tex.GetNativeTextureID (), m_ChannelTextures[2].tex.GetNativeTextureID ());
    4.     GL.InvalidateState();
    5. #else
    thanks a lot and sorry for the late reply
     
  31. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    Great, thanks rogelio!
     
  32. rogeliopuig

    rogeliopuig

    Joined:
    Dec 29, 2011
    Posts:
    13
    We are developing this application with video textures and after a few plays and stops, I get a Memory Warning Level 1, and after a few more steps, the application gets a Memory Warning Level 2 and crashes.
    Thanks in advance.
     
  33. rogeliopuig

    rogeliopuig

    Joined:
    Dec 29, 2011
    Posts:
    13
    More info on Memory Warning.
    I've noticed that the number of Textures incresases by 3 each time the funtion Play in MobileMovieTexture is called.
    I reckon it has something to do with the destructor of the m_ChannelTextures.
    Every time the movie is played, AllocateTexures is called and creates a new array of 3 ChannelTextures.
    When stopped, those textures are supposed to be freed by garbage collector but they are not.
    Does it make sense?
    Thanks a lot
     
  34. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    Makes sense. I had a suspicion they might not be getting freed correctly.

    would you try something for me please?

    Switch the tex = null to MonoBehaviour.Destroy(tex); in ChannelTexture.Destroy, so it looks like this

    Code (csharp):
    1. public void Destroy()
    2. {
    3. #if !((UNITY_ANDROID || UNITY_IPHONE)  !UNITY_EDITOR)
    4.     pixels = null;
    5.     handle.Free();
    6. #endif
    7.     MonoBehaviour.Destroy(tex);
    8. }
    Thanks for the additional information :)
     
  35. rogeliopuig

    rogeliopuig

    Joined:
    Dec 29, 2011
    Posts:
    13
    Hi, just tested and It doesn't work as expected. Destroy is called Just when destroying the object and Allocate is called at each Play() call. So Destroy() will just delete the latest 3 created textures. So Destroy should be called at each Stop. I've made that modification you told me and a few more. to fix what said above
    Code (csharp):
    1.     void Close ()
    2.     {
    3.         if (m_nativeContext != IntPtr.Zero) {
    4.             CloseStream (m_nativeContext);
    5.            
    6.             m_nativeContext = IntPtr.Zero;
    7.             DestroyTextures(); //Added Line
    8.         }
    9.        
    10.     }
    11.  
    12.     void OnDestroy ()
    13.     {
    14.         Close ();
    15.        
    16.         //DestroyTextures (); //Removed line
    17.     }
    The Movie can be stopped and played so many more times before crash (almost 300) but still getting a crash, this is the console error message
    Code (csharp):
    1. project(3126,0x3f52b48c) malloc: *** mmap(size=528384) failed (error code=12)
    2. *** error: can't allocate region
    3. *** set a breakpoint in malloc_error_break to debug
    4. Current language:  auto; currently c++
    5.  
    see attached image for stacktrace
    Note that to avoid other type of leaks, i call System.GC.Collect and Resources.UnloadUnusedAssets(); when the application receives a memory warning
    Thanks a lot for your help, note that our application will be an installation and we don't want any memory leak crashing it

    Thanks again!
     

    Attached Files:

  36. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    Good catch, DestroyTextures should be called from close.

    I'll try and track down the leak. There must be a way of profiling allocations.

    As a sticky tape fix, technically if your movie is the same dimensions, it doesn't need to allocate the textures again.
     
    Last edited: Jan 14, 2012
  37. rogeliopuig

    rogeliopuig

    Joined:
    Dec 29, 2011
    Posts:
    13
    Well, I think that from now, the problem is in Unity's memory manager
    That fix would be really helpful. Could you Post it? That would solve part of my problem.
    Thanks!
     
  38. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    Could you PM me your email and I'll send it to you for testing. Thanks
     
  39. golden_gate

    golden_gate

    Joined:
    Jul 22, 2009
    Posts:
    81
    I tried the demo version ... Does this only support ios pro?
     

    Attached Files:

  40. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    I am very sorry, I thought that all versions supported native plugins. See the "Native Code Plugins Support" row in this table http://unity3d.com/unity/licenses, turns out everything apart from the free version supports them.
     
  41. golden_gate

    golden_gate

    Joined:
    Jul 22, 2009
    Posts:
    81
    I have iOS (paid version.)

    The grid on the license page says it supports native plug ins.
     
  42. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    Excellent, then you should definitely be able to run it on an iOS device
     
  43. golden_gate

    golden_gate

    Joined:
    Jul 22, 2009
    Posts:
    81
    The issue I am having is in the game view ...when on the "iPhone, iPod Touch, iPad" mode editor.

    Does this only run on a device and not in scene and game views?
     
  44. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    With pro, it runs in the editor, there are no unity plugin error messages. Looking at the licence table, it should still run on a iOS device.

    I'm sorry golden_gate, I don't make the rules...
     
  45. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    New version supports chroma keying for cutting out a color with an alpha channel.

    See attached screens
     

    Attached Files:

  46. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    For those awaiting the update, I'm sure *someone* will look at it soon.

    Sorry about the delay, it is out of my hands

    $AssetStore_Sigh.png
     
  47. SevenBits

    SevenBits

    Joined:
    Dec 26, 2011
    Posts:
    1,953
    I'm sorry if this is a stupid question, but does this support Unity Indie? I know Pro is required for videos.
     
  48. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    Sorry SevenBits, pro is also required for native plugins and this is a native plug in :-(

    I should add that to the first post, thanks for reminding me :)
     
  49. SevenBits

    SevenBits

    Joined:
    Dec 26, 2011
    Posts:
    1,953
    Oh, that's a shame. Any chance you could make it .NET? I don't have the money to buy Unity Pro, and could really use this.
     
  50. DanTreble

    DanTreble

    Joined:
    Aug 31, 2010
    Posts:
    590
    Sorry SevenBits, there are thousands of lines of c code I would have to rewrite.