Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

[RELEASED] MPMP - cross platform video solution

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

  1. wxxhrt

    wxxhrt

    Joined:
    Mar 18, 2014
    Posts:
    151
    Hi, I'm using the demo package on OSX to play back 6 separate 5 second h264 mp4's, each is on a separate quad and I'm Unity has slowed to around 45-60fps. Is there anything I can do to get higher Unity framerates? I've tried mjpeg codec with similar results. Thanks
     
  2. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Hi, what GPU do you have? As MPMP uses the GPU mainly this has a huge impact on the performance.
     
  3. wxxhrt

    wxxhrt

    Joined:
    Mar 18, 2014
    Posts:
    151
    It's a 2gb nvidia gt750m
     
  4. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    I would not expect miracles from this GPU ;) I'll expect that you will see a real performance boost when using a card in the range of a GTX 960-980 .
     
  5. wxxhrt

    wxxhrt

    Joined:
    Mar 18, 2014
    Posts:
    151
    Ah wow! Ok that rules out using MPMP for this project- thanks for your quick replies and having a demo version available :)
     
  6. wxxhrt

    wxxhrt

    Joined:
    Mar 18, 2014
    Posts:
    151
    Hi again, just trying to write some very simple code to play back a clip on a texture- could you give me a pointer in the right direction- I thought the following would work but no luck with it.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using monoflow;
    4.  
    5. public class MPMPTester : MonoBehaviour {
    6.  
    7.     MPMP mpmp;
    8.     public string videoPath;
    9.     // Use this for initialization
    10.     void Start () {
    11.  
    12.         string thePath = Application.dataPath + "/StreamingAssets/" + videoPath;
    13.  
    14.         mpmp = new MPMP ();
    15.         mpmp.videoPath = thePath;
    16.         mpmp.SetVideoMaterial(this.GetComponent<Renderer>().sharedMaterial);
    17.         mpmp.texturePropertyName = "_MainTex";
    18.         mpmp.SetUpdateFrequency (60f);
    19.         mpmp.Load();
    20.         mpmp.looping = true;
    21.         mpmp.Play();
    22.  
    23.     }
    24.    
    25.     // Update is called once per frame
    26.     void Update () {
    27.    
    28.     }
    29. }
    30.  
     
  7. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Best is to look into the MPMP_APITest script. to get a picture how to use the scripting API. You should work with the OnInit callback to make sure that the native part is proper initialized before loading something at Start/Awake . And when creating a dynamic instance of MPMP you should use AddComponent<MPMP>() ( new() doesn't work with classes that based on Monobehaviours)
     
  8. wxxhrt

    wxxhrt

    Joined:
    Mar 18, 2014
    Posts:
    151
    Ah I see, thanks!
     
  9. GoRiLLa

    GoRiLLa

    Joined:
    Oct 8, 2013
    Posts:
    14
    Great asset! Will buy it without question if it works as advertised over the next couple of weeks.

    Just wanted to let you know that streeaming m3u8 files seems to work on Windows, but not OSX when using Unity 5.3.5 with El Capitan OS. After loading the videoPath the Load and Play buttons in your test scene and MPMP script blinks back and forth.

    Test stream:
    http://vevoplaylist-live.hls.adaptive.level3.net/vevo/ch1/appleman.m3u8

    BTW: Is it possible to stream from youtube on all platforms or is that Windows with VLC-player only?

    Thanks!
     
  10. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    El Capitan has some problems so i can't recommend it at the moment. The youtube player is a VLC only feature but you can buy a third party asses that should work in combination with MPMP for the Youtube url resolving on the other platforms : https://www.assetstore.unity3d.com/en/#!/content/29704
     
  11. AllonXR

    AllonXR

    Joined:
    Jul 16, 2012
    Posts:
    28
    Hi, I'm using the trial version and I managed to get MPMP working quite nicely with GearVR. However, it is unclear to me how I should set things up for cardboard. I have a top/bottom stereo video,but I cannot get them separatedper eye for cardboard. How should I set this up?
     
  12. opertoonist

    opertoonist

    Joined:
    Jul 11, 2012
    Posts:
    145
    Hello—I've been having great luck with the trial and I'm wondering if you're planning to support tvOS in the future? Thanks.
     
  13. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Sorry, but at the moment this has not high priority. Can't make any promises.
     
  14. GarbageCat

    GarbageCat

    Joined:
    Jul 31, 2012
    Posts:
    224
    the sample with watermark does not work with WebGL (unity 5.4.03f)
    I'm getting "error: use of undeclared identifier 'SetCallbackFunction' " while trying to compile it
     
  15. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Sorry, but the WebGL part comes only with the full version because there is no watermark in it. You can contact me directly so i can sent you the files.
     
  16. GarbageCat

    GarbageCat

    Joined:
    Jul 31, 2012
    Posts:
    224
    its alright, bought it but I 'm still getting an error in WebGL
    even with the plugin

    error: conflicting types for 'SetCallbackFunction'
    extern void DEFAULT_CALL SetCallbackFunction(int32_t, Il2CppMethodPointer);
     
    Last edited: Aug 28, 2016
  17. AllonXR

    AllonXR

    Joined:
    Jul 16, 2012
    Posts:
    28
    Any ideas? Anyone?
     
  18. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Hi,
    you should go under player settings/other settings and enable virtual reality. Then you have on each camera in your scene the additional option to select to which eye the camera should render.
     
  19. KarelA

    KarelA

    Joined:
    Dec 30, 2008
    Posts:
    412
    Hello.

    I am trying out the demo version of this plugin and importing it into new project and i get an error.

    PlayerSettings Validation: Requested build target group (15) doesn't exist; #define symbols for scripting won't be added.
    UnityEditor.PlayerSettings:SetScriptingDefineSymbolsForGroup(BuildTargetGroup, String)
    monoflow.MPMP_Editor_Utils:MountScriptingDefineSymbolToAllTargets(String) (at Assets/MPMP/Scripts/Editor/MPMP_Editor_Utils.cs:97)
    monoflow.VLCInit:.cctor() (at Assets/MPMP/Scripts/Editor/MPMP_VLC_Utils.cs:360)
    UnityEditor.EditorAssemblies:SetLoadedEditorAssemblies(Assembly[])

    Any ideas? I am using 5.4.0f3
    Thanks

     
  20. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Hi,
    this is a harmless message. There seems to be a bug in Unity that causes this message when importing or in other rare conditions. It's only editor related.
     
  21. GarbageCat

    GarbageCat

    Joined:
    Jul 31, 2012
    Posts:
    224
    _monoflow could you test if MPMP works for you in WebGL inside an empty project?
    even with the full version it doesn't for me
     
  22. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    I reported a bug to Unity. With Unity 5.3.4 it works but with 5.4.0 i can't publish for WebGL. The il2cpp engine stops.:mad: Thanks for the report.
     
  23. Ajr_1

    Ajr_1

    Joined:
    May 22, 2013
    Posts:
    20
    Hi, I'm testing this out as a replacement to VTP for my app. Quick question before I go too far - can it load video files from the iOS camera roll using the assets-library:// scheme?

    Thanks
     
  24. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Hi,
    i'm not familiar with this and don't know if this works without a problem. You probably will need to convert your address with some other framework method to a normal file path. Best is to test this with the demo verson.
     
  25. KarelA

    KarelA

    Joined:
    Dec 30, 2008
    Posts:
    412
    Unfortunately this error message pops up every time i try to run the sample scene and the video is failing to play. Not sure what i am missing here. Tried several times to create new project and re-import the demo plugin. Always get the same result. And no one other here seems to have this issue. Would like to find a solution for this before making a purchase.

    Thanks.
     
  26. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    change the line 97 in MPMP_Editor_Utils to this:
    Code (CSharp):
    1.  
    2. try {
    3.   PlayerSettings.SetScriptingDefineSymbolsForGroup(_group, string.Join(";", _defineSymbols.ToArray()));
    4. }catch (Exception){ }
    5.  
     
  27. KarelA

    KarelA

    Joined:
    Dec 30, 2008
    Posts:
    412
    Still the same result. For just in case i attached the screenshot for the changed lines in order to make sure if i did it correctly. Double tapping on to the error brings me there.
     

    Attached Files:

    • pic.jpg
      pic.jpg
      File size:
      171.3 KB
      Views:
      434
  28. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Then i would comment out the whole line (also in line 117) . If you do this and want to switch between the VLC and Media Foundation backend you have to add or remove the scripting define Symbol 'VLC_BACKEND' by hand under Playersettings/Other settings/Scripting Define Symbols.

    What OS are you on and what publish platforms do you have installed in Unity?
     
  29. KarelA

    KarelA

    Joined:
    Dec 30, 2008
    Posts:
    412
    I am on Windows10 but my app must run on Windows7, 8 & 10
     
  30. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Here is a fix to this issue: on line 90/107 just add an additional check. As the VLC_BACKEND define symbol only matters on Windows we don't need to iterate over the whole enum.
    Code (CSharp):
    1.  if (_group == BuildTargetGroup.Unknown) continue;
    2. if (_group > BuildTargetGroup.Standalone) continue;//additional check
    (I realized that this behaviour depends on your installed build platforms so not every user faces this issue)
     
  31. OhmGym

    OhmGym

    Joined:
    Sep 1, 2016
    Posts:
    1
    Since it#s the first time we need Video playback in our Projects I'm looking for a Video asset with a simple solution for Video with alpha channel. All the solutions with custom shaders I read about in the Forums seem quite cumbersome to me. Does MPMP provide a easier way for Videos with Alpha channel?
     
  32. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Hi,
    MPMP doesn't support video codecs with alpha , only a shader based solution.
     
  33. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    I just purchased MPMP and I'm incredibly happy with it.

    I am however wondering whether if is possible to use an AudioSource component to play the audio, instead of playing the audio directly from the clip.

    I was very surprised to find that the documentation doesn't mention this at all.
     
  34. KarelA

    KarelA

    Joined:
    Dec 30, 2008
    Posts:
    412

    Thank you. This worked. I purchased the asset and i am happy with it.

    Out of curiosity. I also tested on Android with the sample video that was provided. For some reason i get the white screen. Are you able to tell what might be the issue here?
    Thanks.
     
  35. thomaswollbekk

    thomaswollbekk

    Joined:
    Aug 11, 2016
    Posts:
    2
    Hi! :)

    Any ideas why I have no audio when running on iOS 9 and OSX 10.11.1? Everything works fine on Windows. (Except a crash on windows 10 (VLC) when I have looping set to true, but I circumvented this by making my own looping method)

    The videos runs fine with audio on my iPad and iPhone using the standard video player for iOS. (H.264, AAC, mp4)

    Oh and I almost forgot. On Windows 10 everything works fine in the editor, but after I make a standalone build no videos will load even though they are still located in StreamingAssets.

    Cheers!
     
  36. Elfteiroh

    Elfteiroh

    Joined:
    Mar 5, 2014
    Posts:
    4
    Hello!
    I seem to have trouble loading the plugin on some Android devices, mainly ones that aren't compatible with OpenGLESv3, only with OpenGLESv2. There is an error saying stuff like
    "dlopen("/mnt/asec/com.studio.game-2/lib/libMPMP.so") failed: dlopen failed: could not load library "libGLESv3.so" needed by "libMPMP.so"; caused by "libGLESv3.so" is too small to be an ELF executable"
    followed by
    "Unable to find MPMP" then "DllNotFoundException: MPMP"
    each time the code try to call it.
    It works "fine" with other devices (I have a weird bug where the video start playing fine but after 4-5 seconds, it suddenly start rendering bigger than the texture, but it may be the video codecs or something), and it just stop working everywhere if I force OpenGLESv2 in the player settings. This may be a demo-only bug though, I still haven't got permission from my boss to buy the plugin.
    Thanks, the plugin is really great by the way, it was very easy to setup for iOS! :)
     
  37. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Hi,
    there seems to be some backward compatibility issues with OpenGL 3.0 on older hardware. I will make a second Android dll that is only OpenGL 2.0.
     
    Elfteiroh likes this.
  38. Elfteiroh

    Elfteiroh

    Joined:
    Mar 5, 2014
    Posts:
    4
    Oh wow! Thank you very much! The quick reply and good news is very appreciated. :)
     
  39. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Hi,
    you can't use an audio source component as the audio comes directly from the media framework and so bypass Unity.
     
  40. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    There seems to be a bug in Unity 5.4.0 and using a RawImage on iOS.
    The uvRect is now wrong and you will see only a part of the video texture. I made some test and could find a pattern how you can calculate the right uvRect:

    1920x1080 => uvRect.w : 1.07 (2048/1920) , uvRect.h: 1.89 (2048/1080)

    1280x720 => uvRect.w : 1.6 (2048/1280) , uvRect.h: 1.42 (1024/720)

    640x480 => uvRect.w : 1.6 (1024/640) , uvRect.h: 1.066 (512/480)

    So you need to divide the power of two value where the divisor fits in by the texture dimension part.

    (Under Unity 5.3.4 there is no issue.)
    I reported a bug to Unity.
     
  41. StaffanEk

    StaffanEk

    Joined:
    Jul 13, 2012
    Posts:
    380
    That's a shame. Especially for internet streaming content.
     
  42. fred-eai

    fred-eai

    Joined:
    Oct 18, 2014
    Posts:
    5
    Wonderful asset!

    Works great with 360 degree video content, but I'm wondering what needs to be done for 180 degree video content.

    EDIT: Also, is it possible to switch between different quality streams when playing a YouTube video?
     
    Last edited: Sep 7, 2016
  43. Play_Edu

    Play_Edu

    Joined:
    Jun 10, 2012
    Posts:
    719
    Hi,

    i have 2 video And Both Video have same Duration like 3.2. Also i made 2 Button so when i click on first Button then first Video play and click on second one Then second one play y But I want Play both Video With same Duration like
    When i load First Video and seek at 1.5 and i press second Video Then second one play With 1.5 Duration. Its Work But many time it's Crash.

    please Help me.
     
    Last edited: Sep 7, 2016
  44. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    Hi,

    I have tried adding this in and no luck. The video is still causing issues. Our videos are 1370x768, so I am using the following code:
    Code (CSharp):
    1.  
    2. Rect uvr=_rawImage.uvRect;
    3.  
    4. #ifUNITY_IOS&&!UNITY_EDITOR
    5. uvr.width = (float)(2048f / 1370f);
    6. uvr.height = (float)(1024f / 768f);
    7. #endif
    8.  
    9. uvr.y=1f;
    10. uvr.height*=-1f;
    11.  
    12. _rawImage.uvRect=uvr;
    13.  
     
  45. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    As MPMP provides a Texture2D it's more a question of your mesh and the right uv so that you can display the video texture the right way. For a 180 degree you can use a Hemisphere for example. But the uv mapping of your mesh could be an issue. For my examples i used a sphere that i created with Primitive Pro (which i highly recommend). With this asset you can get most of the meshes you need with the right uvs .
     
  46. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    The WebGL publish should be working again in the next official Unity 5.4.1f1 version. With the latest 5.4.0p4 version (identical to 5.4.1f1) it works already. :)
     
  47. fred-eai

    fred-eai

    Joined:
    Oct 18, 2014
    Posts:
    5
    Thanks! I did make a hemisphere with modo, but didn't finish with the uv mapping. Glad I was on the right path. :)

    On the edit, is it possible to switch between different quality streams when playing a YouTube video?

    Also, I noticed that my scene hangs (and never loads) depending on the YouTube video I try to load. Anyone have experience with this issue? Happening with canvas > rawImage.
     
  48. guselm

    guselm

    Joined:
    Sep 9, 2016
    Posts:
    3
    Hi!

    I'm looking at the mpmp DemoSetup, and around 1:15 you add Quad to videoHost in the mpmp instance. There is no such thing on the version I downloaded.

    Is videoMaterial the same? I can't drag my Quad to that box...

    EDIT:

    Also, around 0:40 you drag a New Material as Element 0 to the Quad, what is that?
     
  49. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Hi, the video is a bit outdated. I changed this so you don't have to specify a videohost anymore. You just set the videoMaterial. You can add this material to your meshes that should display the video texture. (RawImage components get the videoTexture directly via the MPMP_ugui_Element script)
     
    guselm likes this.
  50. guselm

    guselm

    Joined:
    Sep 9, 2016
    Posts:
    3
    I'm sorry for being dumb. This is the first time I'm using Unity.

    But I don't understand what you mean... I just want to do exactly as the layout you have on the demo video. Is there any updated guide?
     
unityunity