Search Unity

[RELEASED] MPMP - cross platform video solution

Discussion in 'Assets and Asset Store' started by _monoflow, Jan 25, 2016.

  1. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Tried it by myself and had no issues. (Windows 8.1 64 bit with VS2015) only a warning that BoxColliders does not support negative scale or size which is harmless.
     
  2. RicardoViana

    RicardoViana

    Joined:
    Feb 16, 2015
    Posts:
    13
    have to rebuild everything from scratch then. it works on new projects, but this one got broken.
     
  3. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    You can try to remove the whole MPMP folder, close Unity reopen Unity .If there is new MPMP folder delete it again, restart Unity and reimport MPMP.
     
  4. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    There is a bug in the current version 1.4 for Android:
    Please comment out on MPMP.cs the line 477 :
    Code (CSharp):
    1.  if (!IsPlaying() && !_seeking) return;
    This is a regression bug on Android that cause problems playing videos if you use the OnLoad callback.
    Tomorrow i will upload a new version with a fix and some other modifications.
     
  5. RicardoViana

    RicardoViana

    Joined:
    Feb 16, 2015
    Posts:
    13
    It worked! great! Thanks!

    Now a different issue. We are using MPMP as VR video player and use 4k mp4 videos.
    On my machine a windows 10 with GTX980ti , i can play flawlessly every clip that Windows Movie Player can play.
    But on Windows 8 we get all sorts of artifacts and speed changes in the clips.
    We have tried a bunch of different encode settings and none has proved to work. They all play in WMP win8 but very inconsistent playback in Unity MPMP.

    We thought that could be something in the Media Framework of Windows 10 that makes it work and not in win8.
    But we tried on a Beast HP Workstation with dual XEON and dual Nvidia M6000 with win10, and got same bad results.

    I also tried forcing it to dx11 and dx9 , and automatic graphics. No diference.

    any thoughts?


    best regards
    Ricardo
     
  6. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    What GPU do you have on the Win 8 machine? I had very different kind of playback behaviour on the same machine with a ATI HD7750 and a GTX970. If the GPU is not capable enough it seems that Media Foundation falls back into a CPU encoding so you loose the hardware acceleration. Check the Windows process manager.
     
  7. RicardoViana

    RicardoViana

    Joined:
    Feb 16, 2015
    Posts:
    13
    Nvidia gtx980.
     
  8. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    I uploaded a new version (the demo version is already updated online):

    Version 1.5 - 2016.03.18

    • On Windows with NVIDIA cards the videoMaterial now displays a texture while loading.(The texture that the material has attached when you are in editor mode)
    • Improved error handling on Android when a video could not be loaded
    • Changed the last direct native API calls from the uGUI to a cached version
    • Removed some double update callings on OSX
    • SetVideoMaterial method update
    • Added a PreferenceItem for MPMP to change the scripting define symbol SEEK_TOLERANCE (seek mode on iOS/OSX) via 'Edit/Preferences.../MPMP'
    • Fixed regression bug where events are not called (Android)
    • Added a video synchronizer script
    • Added an Unlit AlphaMask shader
    • Documentation update
     
  9. concrete_vytautas

    concrete_vytautas

    Joined:
    Feb 24, 2016
    Posts:
    3
    @_monoflow it looks, that last update broke something on iOS/OS X, on iOS - app get killed after memory warning, and on OS X VTDecoderXPCService process doesn't exit until you close Unity editor it self. And the bad side of this is - it uses really a lot of memory. Although I haven't tested it outside unity editor.
     
  10. ibps13

    ibps13

    Joined:
    Oct 6, 2012
    Posts:
    113
    @_monoflow Hi, tried the demo version of MPMP before buying :) I have somme trouble with Seek and SeekTo.
    I use streaming video (.mp4) work fine but I wouldlike to seek video to get image and pause it.
    I use :
    Code (CSharp):
    1.  mediaPlayer.autoPlay = false;
    2.             mediaPlayer.looping = false;
    3.             mediaPlayer.volume = 0f;
    4.  
    5.             mediaPlayer.Load(loadPath);
    6.             while (mediaPlayer.IsLoading())
    7.             {
    8.                 yield return new WaitForSeconds(1f);
    9.             }
    10.             PlayVideo();
    11.             mediaPlayer.SeekTo(12f);
    12.             mediaPlayer.SetSeeking(true);
    13.             yield return new WaitForSeconds(1f);
    14.             mediaPlayer.Pause();
    But seek don't work on editor and android

    I loosing somthing ?
    Thanks

    Unity 5.3.4f1, android 5.1.1
     
  11. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    I have uploaded a new demo version (1.5.1) . There where two memory leaks. One was related to the El Capitan fix when a PixelbufferError occurs, the other was only related to the demo version where i didn't clean up the FBO for the watermark when loading a new video.
    If someone needs the fix for the Assetstore version before it's online please contact me.
     
  12. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Do you use live streaming? Then seeking doesn't work (as it's live)
    And setting the seek position is only possible in normalized values. So if you want to seek to a point in seconds you have to convert your value like this:
    Code (CSharp):
    1. mediaPlayer.seekTo(  12f/ mediaPlayer.GetDuration()  );
     
  13. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Fortunately i submitted the new 1.5.1 hotfix right before Unity accepted the new version so 1.5.1 is now also on the Assetstore available. :)
     
  14. ibps13

    ibps13

    Joined:
    Oct 6, 2012
    Posts:
    113
    Thanks monoflow, tried this: but not work
    Code (CSharp):
    1. float variable = (float)mediaPlayer.GetDuration();
    2.             mediaPlayer.SeekTo(12f / variable);
    3.             mediaPlayer.SetSeeking(true);
    It's not a live streaming, video is on http server.
     
  15. Kabutak

    Kabutak

    Joined:
    Feb 27, 2014
    Posts:
    5
    I have a question. We've been working with this plugin in VR and AR applications, often for mobile. Am I correct that it isn't possible to have two separate videos loaded in memory on android currently? Our test application does fine on the desktop, but on the phone only one video loads successfully. I'm going to set it up to dynamically load the videos as need be, just wanted to check that I wasn't missing something here.

    I also wanted to check that it will unload the video when I load another one in a separate mpmp instance, since I can't find an unload function in the player. I'm assuming it will since only one seems to be allowed at a time for android. Thanks a lot by the way, your plugin is a fantastic help for our team, and your active role on the forums is great as well.
     
  16. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    I found a little bug. The IsLoading() method does not update from the internal state and so it pass through immediately.
    I will fix this but you can use right now the OnLoad callback.
    Code (CSharp):
    1. mediaPlayer.OnLoaded += (m) => {
    2.           m.SeekTo(12f/ variable);
    3.         };
     
  17. concrete_vytautas

    concrete_vytautas

    Joined:
    Feb 24, 2016
    Posts:
    3
    @_monoflow OS X memory usage is ok now, thanks!
     
  18. concrete_vytautas

    concrete_vytautas

    Joined:
    Feb 24, 2016
    Posts:
    3
    @_monoflow just tested 1.5.1, still getting memory warning on iOS :/

    My first impression is that some kind of memory leak exists there as well... because at the beginning 4K stream works just fine and then memory warning is fired and app gets stopped. Maybe it's somehow related to the fact that video is lagging a bit...
     
  19. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    You can load several videos at the same time on all platforms.
    But you have to be sure that the videos are right encoded for the platform. Sometimes the audio track makes trouble on Android for example.
    At the moment there is no Unload function. When you call Load(yourNewPath) the player automatically updates with the new content. To stop a player you just call Pause or you can destroy the whole MPMP instance.
     
  20. ibps13

    ibps13

    Joined:
    Oct 6, 2012
    Posts:
    113
    Hey thanks monoflow, yes already used "OnLoaded" works fine :)
     
  21. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    I found another regression bug that causes on iOS some performance problems with large videos.( _videoTexture.Resize is called on every frame even if the video dimension is not changed) Fix comes in the next version. Or you can use the attached new MPMP.cs file.
     

    Attached Files:

    • MPMP.cs
      File size:
      20.9 KB
      Views:
      1,036
  22. Kabutak

    Kabutak

    Joined:
    Feb 27, 2014
    Posts:
    5
    Hm, interesting. I was unable to make multiple instances work at the same time at all on android (GearVR on Galaxy S6). I tried multiple methods, and one always didn't load. I eventually just used one instance and load/unload the videos dynamically then skip to the parts I need, which works fine. Thanks again for the great plugin.
     
  23. Shimizoki

    Shimizoki

    Joined:
    Feb 2, 2013
    Posts:
    5
    @_monoflow:
    After having updated from version 1.2 to 1.5.1 I now crash when your plugin is loaded on android.

    Another note, in 1.2 the plugin worked beautifully when it is in the scene from the very beginning, but when dynamically added at a later date, it seems to work in windows editor, but just display a white/blank screen on android (no audio, no apparent errors). I am unable to test if this is still the case in 1.5.1 due to the aforementioned crash.

    And finally, MPMP_DelayQuit.cs is using the namespace "MPMP", is this supposed to be "monoflow"?

    Over all, your plugin is pretty awesome. Thanks for the hard work.

    Unity: 5.3.2
    Android: 6.0.1
    Phone: Nexus 6

    I/MPMP﹕ Load: <valid file path>
    I/MPMP﹕ scheme: file
    I/MPMP﹕ isOBB:false
    I/MPMP﹕ Reset
    I/MPMP﹕ PrepareAsync
    D/MediaPlayer﹕ setSubtitleAnchor in MediaPlayer
    I/MPMP﹕ onPrepared:
    I/MPMP﹕ GetDuration:566613.000000
    A/libc﹕ Fatal signal 11 (SIGSEGV), code 2, fault addr 0xaecfcff0 in tid 24358 (UnityMain)
     
    Last edited: Mar 23, 2016
  24. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    @Shimizoki I've sent you a pm. And thanks for the hint with the namespace!
     
  25. Shimizoki

    Shimizoki

    Joined:
    Feb 2, 2013
    Posts:
    5
    Just as an update for everyone...

    The plugin author immediately followed up with me via PM and a subsequent email chain to identify a a few bugs that existed both in my code and MPMP. After a few days of discussions he helped me work through any issues I was having. This plugin is better than the rest not only because of the product, but because of the individuals working on it as well!
     
  26. mml

    mml

    Joined:
    Mar 29, 2015
    Posts:
    11
    Dear monoflow team,
    I just tried archiving and uploading a build of my project to TestFlight. Unfortunately XCode couldn't archive the build because of a linker error related to full bitcode support.
    "[...]/MPMP/Plugins/iOS/libMPMP_lib.a(mpMediaPlayer.o)' was built without full bitcode. All object files and libraries for bitcode must be generated from Xcode Archive or Install build for architecture arm64"

    Building in development mode and playing on ios devices works. Only archiving does not. I'm using Unity 5.3.4, XCode 7.3 and MPMP 1.5.1.A rchiving and uploading to TestFlight used to work with older versions of MPMP, Unity & Xcode.

    I'm guessing you need to rebuild the library with the latest XCode? Or maybe I did something wrong?

    All the best,
    Felix
     
  27. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    This is strange. The native lib is compiled with bitcode (Xcode 7.2) . I will upgrade to the latest XCode version and do a recompile.
     
  28. hirokitanaka65

    hirokitanaka65

    Joined:
    Feb 25, 2016
    Posts:
    5
    @_monoflow
    It is possible to play sounds of the video from AudioSource?
     
  29. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    At the moment no. The audio comes directly from the media framework. I will try to find a way but can't make any promise. This is a tricky topic.
     
  30. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    I uploaded a new version (the demo version is already updated online):

    Version 1.6 - 2016.04.01
    • API change: SeekTo(float time,bool normalized) and SeekTo(float timeInSeconds)
      Old seek code has to be changed from normalized values to seconds or you have to use the seekTo method with normalized = true!
    • Video pauses now when you pause the editor
    • Fixed bug with IsPlaying,IsPaused & IsLoading are not updating their status
    • New seekTo example added to MPMP_APITest.cs
    • SetVideoMaterial method update
    • Fixed regression bug with OnApplicationPause
    • Texture is now destroyed also on ATI cards (Windows) when loading to unify the loading behaviour and prevent rare editor crashes
    • GL.IssuePluginEvent is called now on every frame (Android) to prevent update issues with streaming videos
    • Added internal MediaPlayer.onVideoSizeChanged callback on Android. Triggers the TEXTURE_CHANGED event and updates the internal native size variables
    • iOS/OSX native libs compiled with Xcode 7.3
    • Documentation update
     
  31. RicardoViana

    RicardoViana

    Joined:
    Feb 16, 2015
    Posts:
    13
    API change: SeekTo(float time,bool normalized) and SeekTo(float timeInSeconds)
    This is great but we were looking for SeekTo(float milliseconds) functionality so we can sync Spatial Audio with the Video. Or a callback to getCurrentTime(float milliseconds).
    In seconds is not very precise. Is that something you can add to it? Please?
    Thank you!!
     
  32. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    You don't need to use whole numbers as you have a float ;)
     
  33. DCassy

    DCassy

    Joined:
    Aug 14, 2013
    Posts:
    5
    Hi there !
    First thanks for this great plug in. I've been testing the demo version for a while, and I definitely plan to buy it.

    My problem today is with the "override IPod music" options. It seems that even if we choose not to do this in the player settings, when the video plays the iPod music fades and stops...
    Is there a way to set this ?
     
  34. Vern_Shurtz

    Vern_Shurtz

    Joined:
    Mar 6, 2009
    Posts:
    264
    I was using the Demo from a couple weeks ago and I use Playmaker to control everything. Using the Demo all worked fine so I purchased and downloaded the latest 1.6 and installed it. Now I can no longer get the Seek property using playmakers "Get Property" action. It's like it has disappeared. I see you made some changes to seek and now I cannot access it like I did prior.

    And it was working perfectly.... Any help would be appreciated.

    Also, any thoughts to adding full Playmaker support for MPMP so many of us can better work with it?
     
    Last edited: Apr 8, 2016
  35. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Hi, i have to look into this.
    I have to look into this. Right now the media framework just play audio without any further settings.
     
    DCassy likes this.
  36. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    The SeekTo API has changed : MPMP 1.6 release notes.
    The Playmaker support is a good feature request. Is on my ToDo list.
     
    DCassy likes this.
  37. DCassy

    DCassy

    Joined:
    Aug 14, 2013
    Posts:
    5
    This would be great, especially for events that are not accessible right now by playmaker (unless I missed something). I have trouble accessing values too, like "get duration".
     
  38. Vern_Shurtz

    Vern_Shurtz

    Joined:
    Mar 6, 2009
    Posts:
    264
    Seek as it was no longer shows up in Get Properties or Set Properties. That was what I was using to get info such as when the video was finished or to skip to the end or beginning by using Set Seek to 0 or 1. Looking for a workaround. Until then I cannot use MPMP and may have to look elsewhere... The old Seek worked perfectly for me.
     
  39. mml

    mml

    Joined:
    Mar 29, 2015
    Posts:
    11
    Hi there,
    I finally got around to building and archiving my game with MPMP 1.6. Sadly it had the same issue when archiving in XCode:

    "[...]/MPMP/Plugins/iOS/libMPMP_lib.a(mpMediaPlayer.o)' was built without full bitcode. All object files and libraries for bitcode must be generated from Xcode Archive or Install build for architecture arm64"

    This time I found out that I can work around it by disabling Bitcode in my own project. then archiving and uploading to iTunesConnect worked.
    This works fine for my current TestFlight builds, but for shipping I would love to enable Bitcode. During my research I found this link which states you have to archive the library to enable Bitcode support. Maybe it can help you build the library with full Bitcode support:
    http://stackoverflow.com/questions/...debuild-a-static-library-with-bitcode-enabled

    All the best and thanks for the quick turnaround again!
    Felix
     
  40. tiagojcosta29

    tiagojcosta29

    Joined:
    Dec 16, 2014
    Posts:
    31
    I have this weird bug in IOS, when I enter the scene the video plays just fine, but if I go to another scene and go back to the video one, the game just crashes. No error log whatsoever in Xcode... Is this a known issue? Am I missing something?

    Thanks for your help!
     
  41. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Don't know how your scene management is and what you are doing when the scene is loaded, but if you create a new MPMP instance you should let one frame delay between creating the MPMP instance and calling into the plugin. And make sure that you don't have two MPMP instances in your scene that render into the same texture.
     
  42. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    If your using a newer version of Unity 5, when loading a scene make sure you pass in the second parameter as load it as a "Single" scene not "Additive". Not sure if thats the issue, but try it anyway.
     
  43. tiagojcosta29

    tiagojcosta29

    Joined:
    Dec 16, 2014
    Posts:
    31
    I am doing that!
    On the editor mode it works just fine with no errors, but every time I test it on my Ipad it just crashes the second time I enter the scene to play the video. I'm not instantiating nothing new because it's all already in the scene!
     
  44. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    Very strange. Have you tried this in new projects?
     
  45. tiagojcosta29

    tiagojcosta29

    Joined:
    Dec 16, 2014
    Posts:
    31
    yep, and it worked just fine! There must be something on my project that keeps things from running
     
    mimminito likes this.
  46. tiagojcosta29

    tiagojcosta29

    Joined:
    Dec 16, 2014
    Posts:
    31
    Huum I just found out that if I try to instantiate one prefab with the movie plugin in IOS, it crashes the app, although it works fine if the prefab is already in scene. Anyone had this happening before?

    Edit: On my xCode console I'm getting thread 1:EXC_BAD_ACCESS (code=1, address=0x141). Also the xCode points to the GetDuration (its returning 0).
    This only happens in IOS, editor mode shows no error.

    Does anyone knows how to fix this?
    Thank you for your patience!
     
    Last edited: Apr 18, 2016
  47. Arvank

    Arvank

    Joined:
    Aug 7, 2012
    Posts:
    5
    Hey there!
    First off, your app is awesome! I've been looking for something like this for a while now and your app almost perfectly fits the type of player that I need. Unfortunately, I'm having some trouble.

    I noticed you said that the video works for Windows, IOS and Android. However, would this mean it would also support implementation for a project meant to be used in WebGL or the Unity Webplayer? Right now I'm getting a whole slew of errors regarding DLL's when trying to build as WebGL. When building for the WebPlayer, I get two errors stating the following:

    Assets/MPMP/Scripts/MPMP_Utils.cs(85,32): error CS0117: `System.IO.File' does not contain a definition for `WriteAllBytes'
    Assets/MPMP/Scripts/MPMP_Utils.cs(152,36): error CS0117: `System.IO.File' does not contain a definition for `WriteAllBytes'

    These last two errors also seem to pop up immediately whenever I try to pull the project from git onto my other computer, meaning I am not even able to run the application inside the editor, even though it works fine for the editor on my current machine. Both builds are attempted with the default mpmp project, using the "mpmp_basic" scene. I looked over the thread, but haven't really found anyone else with similar issues. If you have any info on this, that would be amazing.

    Thanks in advance!
     
  48. JoaoPaul54

    JoaoPaul54

    Joined:
    Nov 20, 2013
    Posts:
    52
    Hi Kurple, I believe this asset does not works in WebGL.
     
  49. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    It will not work in WebGL unfortunately. To get video to work in WebGL you will need to use native HTML5 video rendering. Unity have release a demonstration plugin of how to get this working on the Asset Store which you can download and tweak for your project:
    https://www.assetstore.unity3d.com/en/#!/content/38369
     
  50. Arvank

    Arvank

    Joined:
    Aug 7, 2012
    Posts:
    5
    Thanks for the prompt reply guys! Quite a bummer, though; it would've been great if the plugin could have done most of the heavy lifting, as I am not that familiar with the inner workings of streamings. Do you think it could be possible to kind of jury-rig it to work with webGL? From what I understand it's currently the DLL's that cause the problems for it, correct? Would it be possible to find an alternative to using those?

    Mimminito, thanks for the heads up! I checked out the plugin and it looks pretty interesting. I haven't gotten Pro (yet) so I can't utilize MovieTexture yet, but I have noticed that in most MovieTexture demonstrations the framerate seems to be quite low. Would this be related to the video being played, or does MovieTexture have a hard time supporting 60 fps streams? Ideally, I am looking for something that would let me stream 4k 360 feeds with m3u8 encoding but so far haven't really been able to find anything that fit those selective requirements.

    Sorry if any of this sounds stupid. I am familiar with the basics of programming, but this is the first time I'm trying something this extensive.