Search Unity

[RELEASED] MPMP - cross platform video solution

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

  1. DerrickBarra

    DerrickBarra

    Joined:
    Nov 19, 2013
    Posts:
    210
    Is anyone else seeing lag spikes of 2-3 seconds when a video starts to play? (Occurs when playing a local 720p file or when playing a youtube video via the "YouTube API V3 + YouTube Video Player" plugin on the asset store).
     
  2. Purpleshine84

    Purpleshine84

    Joined:
    Apr 8, 2013
    Posts:
    194
    I am pretty sure I would like to buy this product, but I have a question about the demo: I want to play my cutscene automatically and when the video ends go to the following scene. Which variable do I use if I want to say for example: if(video ended){Load scene}? I would also like to make a build version of this to see if it works. If everything works, instant buy! @_monoflow
     
    Last edited: Apr 21, 2016
  3. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    You can use the OnPlaybackCompleted event . But you have to set the looping property to false, otherwise the event is not called.
    Just look into the MPMP_APITest.cs file of the demo to get a better picture how to code with MPMP.
     
    Purpleshine84 likes this.
  4. djingel

    djingel

    Joined:
    Apr 25, 2016
    Posts:
    2
    Hi Monoflow,

    Starter programer alert here...

    Any idea how to autoload a video? Should I create a script with

    void Load ()

    And attach it to the camera?

    Thnx for any help
     
  5. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Hi,
    you could use a script like this:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4.  
    5. public class MPMP_Loader : MonoBehaviour {
    6.  
    7.  
    8.     public monoflow.MPMP mpmp;
    9.  
    10.     void Start () {
    11.  
    12.         mpmp.OnInit = (m) => { m.Load(); };
    13.  
    14.     }
    15.  
    16.  
    17.  
    18. }
    This calls the Load method of the mpmp instance when mpmp is ready. (On mobile platforms you need one frame delay so it is safer to use the OnInit event).

    Or you could use this way without events :
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4.  
    5. public class MPMP_Loader : MonoBehaviour {
    6.  
    7.     public monoflow.MPMP mpmp;
    8.  
    9.      IEnumerator Start () {
    10. //safety for mobile
    11.   yield return new WaitForEndOfFrame();
    12.  
    13.      mpmp.Load();
    14.  
    15.     }
    16.  
    17.  
    18.  
    19. }
     
  6. djingel

    djingel

    Joined:
    Apr 25, 2016
    Posts:
    2
    It works, thank you very much, I was looking whole day how to do this.
     
  7. bricktownseo

    bricktownseo

    Joined:
    Sep 13, 2015
    Posts:
    2
    Afternoon! I think I am missing something extremely basic here. When I load up the video and play it in an AR experience, the video is properly oriented for Android. For iOS the video is upside down and backwards (inverted). I have tried using the MPMPScaleFlip but I think I am failing harder than I have before with Unity.

    The experience loads and then after the video is loaded I am using the following code. Would love any feedback to get this right!

    Code (CSharp):
    1. public void _OnPlay(MPMP mpmp)
    2.     {
    3.         Debug.Log("API Test::OnPlay:" + mpmp.name);
    4.         for (int j = 0; j < targets.Count; j++) {
    5.             GameObject tmp = targets [j] as GameObject;
    6.             mpmpPlayer.SetVideoMaterial (tmp.GetComponent<MeshRenderer> ().material);
    7.             #if UNITY_IPHONE
    8.             tmp.GetComponent<MeshRenderer> ().material = mpmpPlayer.GetVideoMaterial ();
    9.             var scaleflip = tmp.AddComponent<MPMPScaleFlip> ();
    10.             scaleflip.axisMode = MPMPScaleFlip.Axis.Y;
    11.             scaleflip.DoFlip();
    12.             #endif
    13.         }
    14.     }
     
  8. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Hi, did you tried it with Axis.X? And don't call the DoFlip after creating an instance dynamically because internally the ScaleFlip script calls DoFlip at Start so you will do a double flip with your extra call.
     
  9. FaramirTFK

    FaramirTFK

    Joined:
    Feb 23, 2016
    Posts:
    10
    Hi again everyone.

    Have you encountered some problems with android 6?
    I just updated my phone (lg g3) which one i have been working since now, and all worked perfectly, i made a VR game with video in a plane and video 360º, but after the update the plane movie doesn´t work but the video 360º it does.
    It´s not a great bug i have another phones to work with and works fine, also in GearVR, just checking if it is a persistent error or just with this phone.
     
  10. bricktownseo

    bricktownseo

    Joined:
    Sep 13, 2015
    Posts:
    2
    @_monoflow I am using catchoom to load AR scenes. It seems that when I am using your plugin with Android the video attaches to the plane just fine and plays just fine. The same code (with no flipping added) doesn't work on iOS. The video will play with the frames being backwards where you can't read the words. Any other suggestions?
     
  11. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    You have to add the scaleflip like in the demos. (On Android the texture is not flipped with this script.)
     
  12. FaberVi

    FaberVi

    Joined:
    Nov 11, 2014
    Posts:
    146
    Is there any video showing stream running on various devices? (Maybe even vr)
     
  13. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    No there is no video. Best is to test this on your own devices with the demo version .
     
  14. joaopaul

    joaopaul

    Joined:
    Feb 1, 2016
    Posts:
    39
    Hey there.

    I'm having a little trouble coming to a solution for an issue I'm having.

    I have a video playing and I wish to swap the video (I cannot create a new one so I have to use the same MPMP instance), problem is, the video flickers white while loading the new one.
    Is there any way to "freeze" the previous video while loading the new one or maybe to keep playing the old one while not loaded?
     
  15. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    For stability reason i have to delete the texture when loading a new video. I thought about doing a texture copy to grab the last video frame but didn't found a performant solution. What you can do is to specify a texture in the material inspector of your video material that should be used as a default texture. MPMP will overwrite this texture while playing video but use this texture while loading. So you can customize at least the appearence while loading.
     
  16. joaopaul

    joaopaul

    Joined:
    Feb 1, 2016
    Posts:
    39
    Shame to hear it :( The snapshot of the last frame would be perfect. But at least it's good to know I can do a "default" one :)
     
  17. Figlesias

    Figlesias

    Joined:
    May 6, 2016
    Posts:
    3
    hi monoflow i have a scene with mpmp, in the unity editor y can see the video loaded from a url, but in the android build i can't (i buyed de asset and i have de 1.6v). the video is mp4 format and i need to load de video when the scene start. (only see the black screen)...

    Sorry for my english
     
  18. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
  19. DIAEC

    DIAEC

    Joined:
    May 8, 2016
    Posts:
    1
    Hi I was building on my ipad and I got this error? I am not sure how to fix it.. It seems the path is not right, I must say I only did the build from unity and straight to xcode I pressed build to the ipad I have connected.

    MPMP error? maybe any help thanks. Screen Shot 2016-05-07 at 23.59.41.png
     
  20. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    In Unity click on the libMPMP_lib.a file and ensure that 'iOS' is checked as platform in the plugins inspector.(Also do this with mpMediaPlayer.h)
     
  21. Figlesias

    Figlesias

    Joined:
    May 6, 2016
    Posts:
    3
  22. Kabutak

    Kabutak

    Joined:
    Feb 27, 2014
    Posts:
    5
    Hey monoflow,

    So far we have been very happy with your plugin, especially working in VR and AR on Android. However, with the latest version of the plugin, we are unable to reliably load and play videos anymore. It works fine in editor, but when loading it on a phone, plays only a black screen on the majority of devices. I just tried a clean project with the plugin and the basic scene. The GUI says that the video was loaded, and shows the correct duration. It also tracks in realtime as if the video is playing, but the objects involved remain black. Is there something that has changed or may have been messed up on my end?

    Thanks.

    Edit: It MAY have something to do with the bit rate, frame size, or frame rate of the video in question, as I made it work with a different video properly. Are there any known limitations in that regard for Android?

    Edit 2: I reduced the bit rate and nothing changed, but reducing the resolution of the video made it able to play on Android. What are the Bit rate/Data rate, Resolution/Frame size, and Frame rate limitations when using MPMP on Android? If you know them, of course. Thanks again.
     
    Last edited: May 9, 2016
  23. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    There where no changes in terms of supported videos/encodings. On Android it is hard to predict if a video could run because of the varying hardware. MPMP does no magic. It uses the Android Media Player. But you have to remind that the system has to share texture memory with the Unity app so on weak hardware it is possible that you run out of texture memory.
     
  24. elenzil

    elenzil

    Joined:
    Jan 23, 2014
    Posts:
    73
    mpmp has worked great for us on iOS and Android devices when we install directly to the device (eg, with HockeyApp),
    but we're finally actually submitting our app to the iOS app store and encountering a bunch of errors around the bundle's Info.plist.

    eg, we get an error about this:

    <key>DTSDKName</key>
    <string>macosx10.11</string>

    which makes sense, since it's an iOS app, not an OSX app.

    i expect we're also going to have trouble with this:

    <key>CFBundleSupportedPlatforms</key>
    <array>
    <string>MacOSX</string>
    </array>

    has anyone encountered this ?
     
  25. Figlesias

    Figlesias

    Joined:
    May 6, 2016
    Posts:
    3
    Solved. the problem was the webserver. thanks monoflow :)
     
  26. Petter-Bergmar

    Petter-Bergmar

    Joined:
    May 11, 2016
    Posts:
    5
    It seems my post disappeared. I'm having problems with Windows 10, on one computer it works, on another it won't load videos from StreamingAssets. In the demo, the Load button turns red when I click it. I have installer vcredist, is there anything else I might be missing? The computer came with Win 10 and DirectX 12 preinstalled.
     
  27. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    What GPU do you have?
     
  28. Kabutak

    Kabutak

    Joined:
    Feb 27, 2014
    Posts:
    5
    Alright, I figured that was the case, thanks again.
     
  29. Petter-Bergmar

    Petter-Bergmar

    Joined:
    May 11, 2016
    Posts:
    5
    Hello! I figured out the solution. The user of the computer had the letter "Ö" in it, and I was running MPMP from the documents folder (within the user folder). So in other words, "Ö" and probably other special characters in video path (StreamingAssets path) will not work.
     
  30. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Well it's always not the best idea to work with umlaute. And MPMP resolves the paths with the NET URI class . I made some additional test with path = Uri.EscapeDataString(path); and this still doesn't work with umlauts. But thanks for the info!
     
  31. yingwang

    yingwang

    Joined:
    May 8, 2016
    Posts:
    5
    Hi monoflow, great plugin!

    Would you happen to have any examples showing how to use the Video Synchronizer functionality?
     
  32. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Hi, i will add a demo Scene in the next version.
    You can create an empty gameobject and add the MPMP_Video_Syncronizer script to it. Then you just add one MPMP instance as master and several MPMP instances as clients. The script then tries to syncronize the playback position from the clients with the master when they run out of sync .(With the threshold value you can tweak the range of the delay the clients could have without synchronizing.If you have a too small threshold the synchronizer can cause playback issues.Best is to leave it at the default value)
    It could be that you should uncomment the WaitForSeconds line in the Start method when you test it on mobile devices.
    You don't have to start the videos manually, the script does this for you after every video is loaded.
     
  33. martin.tazlari

    martin.tazlari

    Joined:
    Apr 20, 2016
    Posts:
    4
    Hi everyone,

    First @MonoFlow for your plugin it's relly awesome. It's still have 2 little issues.

    I'm manage to integrate a sphere and MPMP in a Cardboard project. But the X-flip dosen't work on my phone. I mean, I've add a 360° video and in the preview everything is fine. (I use the MPMP Script Flip) for ajusting the Axes .... Then on my Phone, The X-Axes is inversed... has anyone any Idea ??

    Second things, I'm trying to add a cube inside the sphere and trigger something with de Gaze Look off cardboard... But I can't manage do add a cube in the sphere and see it in the preview... How do I do that ?

    (Sorry for my english, French speaker here)
     
  34. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Hi Martin,
    there is some tiny bug in the scaleflip script. I added my latest version for testing.
    When you add a cube inside your spheres you should check the layer . In my demo scene the both cameras have a culling mask to see only the sphere it should see.So perhaps you should add a third layer for things both cameras should see and add this layer to the cameras culling mask.
     

    Attached Files:

    Last edited: May 18, 2016
  35. martin.tazlari

    martin.tazlari

    Joined:
    Apr 20, 2016
    Posts:
    4
    Hi @MonoFlow

    Thanks for your answer and you're fix !! It's working perfectly !
     
  36. yingwang

    yingwang

    Joined:
    May 8, 2016
    Posts:
    5
    Hi monoflow,

    Thanks for the quick response! I noticed that your docs mentions being able to use the video synchronizer for displaying video and doing alpha masking. If I have two videos, one with the regular 3 rgb channels and the other with the alpha channel, is it enough to just plug each video into the video synchronizer for it to work with transparency?

    Sorry I'm just starting off with Unity. Any help is appreciated! Thanks.
     
  37. joaopaul

    joaopaul

    Joined:
    Feb 1, 2016
    Posts:
    39
    Hello again MonoFlow, tell me, is there any way for me to unload a video? I'm using a pooler in my app (which creates video players on demand) but when getting the nativeSize of a video which was pooled I get the size of the previously used video because I'm looking for it after load... usually it works but since I didn't unload the previous one it gets the native size wrong...

    Edit: Got it working... my stupidity this time again :p
     
    Last edited: May 23, 2016
  38. loko08

    loko08

    Joined:
    Oct 6, 2013
    Posts:
    57
    Hello Monoflow,
    I got this issue and it's sometimes happening on some machines and sometimes on others.

    "Failed to load 'Assets/MPMP/Plugins/x86_64/MPMP.dll' with error 'The specified module could not be found.
    ', GetDllDirectory returned ''. If GetDllDirectory returned non empty path, check that you're using SetDirectoryDll correctly."

    I read on a previous post that it's because of the vc_redist. I tried installing the version included with the plugin, but it's not working either. We just updated to windows 10, installed the redist and then now almost all of the computers are showing the same error excepting mine (running windows 10). Can you please take a look, it completely crashes the game if we are testing in the editor.

    Also it's not like it never worked, videos were fine, they played properly and after updating the computer to windows 10, it stopped working, no matter if I install or uninstall the vcredist x64 and x86. It makes no sense, it doesn't help that I update the plugin and nothing happens.
     
  39. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Sounds strange. Could you test to make a build without entering the play mode? And if you could build are the exe running without a problem? And did you checked in the plugins inspector the platform when selecting the MPMP.dll in the hierachy?
     
  40. loko08

    loko08

    Joined:
    Oct 6, 2013
    Posts:
    57
    I have, the issue is only present in the editor, when building to iOS or android, there's no problem in the build. The platform is set to Editor and Standalone. Haven't done an exe file since we aren't aiming to the platform.
     
  41. loko08

    loko08

    Joined:
    Oct 6, 2013
    Posts:
    57
    ??? Any help ??
     
  42. HuikuShih

    HuikuShih

    Joined:
    Nov 8, 2012
    Posts:
    11
    Does the plugin have the ability to do the runtime loading movies on multiple instances? I tried, and it's fine on mac os, but errors on devices.
     
  43. RicardoViana

    RicardoViana

    Joined:
    Feb 16, 2015
    Posts:
    13
    Hi I havent touched MPMP in awhile and now i need it. Problem is im getting no video. Sound loads fine, but whatever video file i input , nothing! It worked perfectly before, ideas? Unity 5.4 MPMP 1.6
     
  44. RicardoViana

    RicardoViana

    Joined:
    Feb 16, 2015
    Posts:
    13
    SOLVED:
    Found the issue. Using SteamVR default settings is Linear color space. If changed to SRGB it plays correct.
     
  45. _monoflow

    _monoflow

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

    Version 1.7 - 2016.05.31
    • VLC backend for Windows:
      • Windows 7 support !
      • Better streaming support
      • Youtube player
      • Much more supported formats
    • Added 'Prevent flicker' option
    • Added Stop method + event (OnStop)
    • Added STOP button to ugui elements
    • Added SetAudioTrack(index) method. You can now use videos with multiple audio tracks and select one that should be used. Default is 0 for the first audio track.
    • Added HasAudioTrack(index) method to check if an audio track at index exists. -Updated the MPMP_VR_Setup.cs script to work on VR devices without interfering Unitys camera handling
    • Fixed issue with SeekToWithTolerance method missing normalized parameter.
    • Re-added seek property
    • Fixed some errors of status properties not having the right values
    • Documentation update
    If you update an existing project and use the MPMP_ugui_elements you have to check the mode on this elements!
     
    Last edited: Jun 2, 2016
  46. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Wow, Unity was fast this time so the new version is now already live!
     
  47. RicardoViana

    RicardoViana

    Joined:
    Feb 16, 2015
    Posts:
    13
    Crashes every time now. 1.6 was working fine a few minutes ago.
     
  48. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    You should check this if you update an old project:
    "If you update an existing project and use the MPMP_ugui_elements you have to check the mode on this elements!" (As i changed an enum the existing gui elemts have now the wrong mode !)
    And you should test with a clean new project to verify that MPMP has no problem with your system.
     
  49. RicardoViana

    RicardoViana

    Joined:
    Feb 16, 2015
    Posts:
    13
    Its clean new project. i copied the MPMP folders from a previous project with 1.6, and it works.
    but sadly 1.7 no.
     
  50. ReneCyber

    ReneCyber

    Joined:
    Jun 3, 2016
    Posts:
    1
    Hi monoflow,

    I use your plugin but since 1.7 version I can't use it anymore... Everytime I try to play a video Unity Crash and close...

    Any idea

    (Everythings was working fine when I was using the demo of the 1.6 version)