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

[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
    monoflow is proud to anounce the release of:

    MPMP (multi platform media player)

    MPMP is a high performance cross platform media player for Windows, Android and iOS/OSX
    To get the best hardware performance on each platform it uses different media frameworks.
    • Windows: Media Foundation or VLC
    • Android: Media Player
    • iOS/OSX: AVFoundation

    In Unity you have only a unified c# interface you work with, so you don't have to deal with all the platform differences. And finally you have video support in the editor!

    On Windows you can choose between two backends: Media Foundation (for best performance) or VLC (Windows 7 backward compatibility, larger codec and streaming support + Youtube player)

    Now available: http://u3d.as/npz

    VLC standalone version: http://u3d.as/uvL


    We provide a demo version for testing.
    (Draws a watermark onto the video)

    Some impression:


    Setup:



    System Requirements:
    ====================
    Unity 5.3.4 or higher

    Windows:
    Windows 7+ (VLC)
    Windows 8+ (Media Foundation)
    DX11 only!
    Visual C++ Redistributable Packages for Visual Studio 2013 (in the vcredist folder are two installers)
    (https://www.microsoft.com/en-us/download/details.aspx?id=40784 )
    If you don't want to install the full Redistributable Packages you need at least following dlls (located beside your exe):
    msvcp120.dll,msvcr120.dll,vcamp120.dll and vcorlib120.dll

    Android:
    Android API level 15+ (Android 4.03+)
    armeabi-v7a or x86 CPU
    OpenGLES 2.0 or 3.0 as Graphic API

    iOS:
    iOS 6+
    OpenGLES 2.0 or 3.0 as Graphic API

    OSX:
    64 bit system



    FAQ:
    ============
    What shader can i use?
    You can use every shader that has a texture property. So you can use almost every shader that comes with Unity.

    Can i use the videotexture on several objects at the same time?
    If you want to use the videotexture on several objects you can attach the material that your videoHost uses to another GameObject.

    Can i use APK Expansion Files on Android?
    Yes. MPMP checks if the Unity app is an obb file and loads the data in a different way.
    You can leave your videos in the StreamingAssets folder of Unity before you split your APK at built time.

    Can i use 4K movies?
    I tested a 4K movie on Windows 8.1 and it worked with a GTX970 with GPU acceleration.(With a ATI HD 7750 only with CPU fallback).
    On mobile devices this depends on your hardware.(Tested on GalaxyS7, iPad Air 2)

    Why is my video playing in the editor but not on my mobile device?
    Every platform has is own restrictions in terms of video codecs or audio formats. So it is most likely a problem of your video encoding.
    (For example at my tests on Android i had problems with a video that uses mp3 audio compression)
     
    Last edited: Jun 20, 2016
  2. 22

    22

    Joined:
    May 22, 2009
    Posts:
    63
  3. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Streaming live TV works on mobile. I tested it with a german channel. I can post you the url tomorrow. The url of the blender movie is not a real stream but as far as i remember a video that has the faststart feature (progressive streaming) so it should start playing after some time even if is not completely downloaded.But this depends on the current network traffic of the server. Best is to test this with a file from a dedicated server. You can test a video in the browser. If it start playing before it is completely downloaded you know that it is progressive streamable.
     
  4. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Here more info about some Android issues:

    The streaming of live TV cannnels doesn't work on all devices. I assume this depends on the Android OS version of your device. On my Nexus 10 (Android 5.1.1) it works but on my Nexus 7 ( Android 4.4.2) i get errors that the master playlist could not be fetched.

    There is also a difference in the seek behaviour depending on what Android Media Player you use.
    The Android Media Player can use two different players under the hood:
    AwesomePlayer (deprecated) or NuPlayer.
    To change between the two players you can go on your device in the Settings -> Developer Settings -> Media -> AwesomePlayer

    The AwesomePlayer has the better seek performance but causes a tiny new bug: it could be that after seeking, the video image doesn't update for some short amount.( The fix of this issue comes in the next version)
    The silly thing is that the AwesomePlayer is deprecated and the NuPlayer is the default on Android (5+)
     
  5. si1984

    si1984

    Joined:
    Sep 20, 2014
    Posts:
    3
    i get this error from the demo package interested in this but the price i want to make sure will work well

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

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Check your platform please. Normally this comes from the fact that you have the WebGL platform selected in your publish settings. The new Unity installer has this problem as you have to install the Windows platform explicit.
     
  7. si1984

    si1984

    Joined:
    Sep 20, 2014
    Posts:
    3
    ty very much and great work you do
     
  8. joaopaul

    joaopaul

    Joined:
    Feb 1, 2016
    Posts:
    39
    Hello.

    I was trying to use the demo version to create a simple player for ogg files to use in my app.
    I cannot however do anything as I get lots of errors such as:

    Failed to load 'Assets/MPMP/Plugins/x86_64/MPMP.dll' with error 'The operation completed successfully.
    ', GetDllDirectory returned ''. If GetDllDirectory returned non empty path, check that you're using SetDirectoryDll correctly.


    the errors all dance around the dll not being found or loaded. I'm running a windows 10 pc, I installed the vcredist packages and I can find the dll in the expected folder.

    The configurations are as default but I do not see anything blatantly wrong.

    Best regards,
    João Paul
     
  9. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Silly that it works on my machine without a problem so i can't really check what the problem is.
    Did you installed the package for both platforms with admin rights and made a restart of Windows?
    Beside that please read the documentation about the supported media formats. ogg files could only played on Android as far as i remember.
    https://msdn.microsoft.com/en-us/library/windows/desktop/dd757927(v=vs.85).aspx
    http://developer.android.com/intl/ko/guide/appendix/media-formats.html
    https://developer.apple.com/library...honeOSTechOverview/MediaLayer/MediaLayer.html
     
  10. joaopaul

    joaopaul

    Joined:
    Feb 1, 2016
    Posts:
    39
    Yup, I just re-installed them and the error still persists.

    I'm attaching a screenshot of my current situation. Hopefully it's just something stupid of me.

    edit: Some extra info. I'm using Unity 4.2.4f1 and the errors appear as soon as I start the scene.
     

    Attached Files:

    Last edited: Feb 1, 2016
  11. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    You can use Dependency Walker (http://www.dependencywalker.com/) to check if there is some other dll missing.
    Just drop the MPMP.DLL into Dependency Walker and on the left side you see what DLLs the MPMP.dll needs. If there is a yellow questionmark it tell you that a reference is missing.(Best is to collapse all in the hierarchy view of Dependenc Walker)
     
  12. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    You wrote that you using Unity 4.2.4 . MPMP is for Unity 5 !
     
  13. joaopaul

    joaopaul

    Joined:
    Feb 1, 2016
    Posts:
    39
    I meant 5.2.4f1. Sorry, that was my bad.
    I'll try the dependency walker. Thanks for the help.
     
  14. joaopaul

    joaopaul

    Joined:
    Feb 1, 2016
    Posts:
    39
    Ok, after some fiddling around I ended up making a fool of myself.

    I mean, I still cannot run it in the editor at all but if I build the scene it suddenly works well.
    Any ideas if this is some configuration or blatant stupidity of mine?
     
  15. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    On Windows it uses other dlls than on Android or iOS/OSX so it is not a miracle that it works on other platforms then Windows.
    There seems to be an issue with the vcredist package installation (This is only an issue for Windows) . Don't know if this is a general issue of Windows 10 or if it depends on the admin rights of the user that tries to install the vcredist package.
    Did you run the installer with 'run as Administrator' ? (I read somewhere that there is a difference between 'run as admin' and your user account admin rights)
     
  16. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    I noticed that on Android, if we build your demo scene when the app goes into the background the audio carrie son playing (and presumably the video). Could you pause/stop the video/audio when in the background and resume when in the foreground please.

    Second, could you add in some events. The ones we would need are OnVideoStart, OnVideoEnd, OnVideoReady(when the video file is ready to be played). That would be great!
     
  17. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    The background audio bug will be fixed in the next release. And events are also in the pipeline.
     
    mimminito likes this.
  18. joaopaul

    joaopaul

    Joined:
    Feb 1, 2016
    Posts:
    39
    Ok, I believe I found the issue.

    By going through the hierarchy of the dll I found out that the dll's missing are the debug ones from VS2013.
    Since these are not redistributable it would be hard for someone without an installation (new or old) of VS2013 to enable this to work.

    Once built, the dll's used will not be the debug versions and as such the vcredist (which contains only the distributable versions) will work.

    Now, I do not know the best workaround to this but one step would be to compile the dll using VS2015 as it is the VS that comes with Unity.

    If by any chance I'm wrong then I have no idea.

    I already installed all the vcredists I could (and yes, with "run as administrator") and tried all the google searches I could find about similar issues...


    edit: I built it for windows... so it's not a cross-platform issue.
     
  19. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Thanks for the info! I will check the compiler settings. perhaps i missed something to prevent referencing the debug dlls.
    Perhaps it is a better idea to use VS 2015. I will think about it.
     
  20. joaopaul

    joaopaul

    Joined:
    Feb 1, 2016
    Posts:
    39
    You're welcome.

    Is there any chance that I can get the updated version once you finish it? (demo one as I'm still trying to see if your plugin works for my needs)

    Currently I cannot do preety much anything in editor as any reference to mpmp spams me with error messages :p
     
  21. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    I will post a message when there is a new demo version with the latest fixes available.
    [Edit]
    Thanks to joapaul there is a fix for the vcredist trouble. I provide a new MPMP.dll for Windows x86_64 that has no referencies to the debug.dlls so it should work now on Windows with a normal vcredist installation
    http://workspace.monoflow.org/mpmp/x86_64/MPMP.dll
    [/Edit]
     
    Last edited: Feb 2, 2016
  22. joaopaul

    joaopaul

    Joined:
    Feb 1, 2016
    Posts:
    39
    Great work and thanks for the help.

    Another question that I found out not to be so easy to answer...

    How would one go in order to find the native size of a movie BEFORE playing it.
    I tried the GetNativeVideoSize() function but it will only give me a value different than (0, 0) after the movie is playing.
    I believe knowing it before hand would be a good improvement as it would allow for re-scalings before a movie begin.

    Anyway, I'm currently pre-loading the video out of the viewport and at least for my proof of concept it works.

    Just waiting for the thumbs up for buying the asset ;)
     
  23. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    I currently try to improve the system with some event handling. So you get some callback events you can react to. (OnLoaded, OnStart...) I have to look into the code but in general it should be possible to get the native size after you loaded. In the Editor/Windows version it works as i need the native size for the preview in the inspector.
     
  24. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Just found another bug that will be fixed in the next release:
    If you want to publish on Android with 'Split Application Binary' you will get an exception.
    I forgot to provide the zip_file.jar with the package. For a quick fix just put the zip_file.jar from here into the MPMP/Plugins/Android folder beside the MPMP.jar .
     
  25. 22

    22

    Joined:
    May 22, 2009
    Posts:
    63
    TV streaming is a hot topic.
    Unfortunately I am struggling with it. I cannot get it working with the trial version. Would you have a code snippet or at least a screen shot with the correct settings for the TV streaming URL? That would help a lot. Thanks
     
  26. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    I made a test with your url and it worked.
    http://vevoplaylist-live.hls.adaptive.level3.net/vevo/ch1/appleman.m3u8 or http://daserste_live-lh.akamaihd.net/i/daserste_de@91204/master.m3u8

    Just copy and paste the urls into the videoPath field of MPMP.

    But as i sad earlier: On Windows this doesn't work. Only on Android/iOS/OSX
     
  27. joaopaul

    joaopaul

    Joined:
    Feb 1, 2016
    Posts:
    39
    I created a small extra for your plugin to allow for small jumps in the movie. This was done for an internal need but just in case anyone wants or needs it I'll leave it here.

    first of all, add the 2 new modes (SEEKFORWARD and SEEKBACK ) to the enum in MPMP_ugui_Element
    It will look like this:

    Code (CSharp):
    1. public enum Mode { LOAD, PLAY,PAUSE,SEEK,LOOP,AUTOPLAY,VOLUME,TEXTURE,SEEKFORWARD,SEEKBACK }

    then in the case switches just add the following ones:

    Code (CSharp):
    1.  
    2. case Mode.SEEKFORWARD:
    3.     OnSelected = new Action(() => {
    4.         player.Pause();
    5.         player.SeekTo((float)(player.GetCurrentPosition() + SeekAmountField * ((float)player.GetDuration() / 1000f)));
    6.         });
    7.     break;
    8. case Mode.SEEKBACK:
    9.     OnSelected = new Action(() => {
    10.         player.Pause();
    11.         player.SeekTo((float)(player.GetCurrentPosition() - SeekAmountField * ((float)player.GetDuration() / 1000f)));
    12.         });
    13.     break;

    EDIT: Just noticed that I did not say it before. You have to create a public variable called SeekAmountField of the float type. If needed just add the following code to the variable list in the script.

    Code (CSharp):
    1. public float SeekAmountField = 1;
    And here is the code for a small editor change that allows for this modes to have a dynamic time value

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3.  
    4. namespace monoflow
    5. {
    6.     [CustomEditor(typeof(MPMP_ugui_Element))]
    7.     public class Ugui_ElementEditor : Editor
    8.     {
    9.         public SerializedProperty Mode;
    10.         public int SeekAmountField;
    11.  
    12.         void OnEnable()
    13.         {
    14.             // Setup the SerializedProperties
    15.             Mode = serializedObject.FindProperty("mode");
    16.         }
    17.  
    18.         public override void OnInspectorGUI()
    19.         {
    20.             MPMP_ugui_Element targetScript = (MPMP_ugui_Element)target;
    21.             EditorGUILayout.PropertyField(Mode);
    22.  
    23.             targetScript.mode = (MPMP_ugui_Element.Mode)Mode.enumValueIndex;
    24.             targetScript.player = (MPMP)EditorGUILayout.ObjectField("Mpmp Player", targetScript.player, typeof(MPMP), true);
    25.  
    26.             if (targetScript.mode == MPMP_ugui_Element.Mode.SEEKFORWARD || targetScript.mode == MPMP_ugui_Element.Mode.SEEKBACK)
    27.                 targetScript.SeekAmountField = EditorGUILayout.IntField(new GUIContent("Amount"), 1);
    28.  
    29.             serializedObject.ApplyModifiedProperties();
    30.         }
    31.     }
    32. }
    Think that is all but it shouldn't be hard to find anything missing if I forgot something...
     
    Last edited: Feb 5, 2016
  28. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Cool!! Many thanks! :)
     
  29. mfleurent

    mfleurent

    Joined:
    Mar 5, 2015
    Posts:
    25
    hi _monoflow,

    i'am very interested in your asset, but the no win 7 compatibility is a no go for me

    i tested the demo package and it seems to work on android, but i'm running unity on a win 7 computer and it screw up the mpmp inspector gui, plus an overflood of error message about the dll can't be loaded

    i hope you'll consider the win 7 implementation
    anyway, great asset you have here
     
  30. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    I'm aware of the problem that there is no Windows 7 support. I have evaluated some solution but it is very complex and hard to find the right way as Microsoft has 1000 different ways to implement it. Can't make any promises at the moment. I want to polish the current version first.
     
  31. joaopaul

    joaopaul

    Joined:
    Feb 1, 2016
    Posts:
    39
    Why is it an issue?Just curious as I ahve no idea :x
    Isn't media foundations for anyindows starting on vista?
     
  32. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Yes, but depending on the way how you implement it you can use features that are only available on certain Windows versions. For Windows 7 i have to use a very complicated way that i didn't had to use when i decided to choose the Windows 8 requirements.
     
  33. joaopaul

    joaopaul

    Joined:
    Feb 1, 2016
    Posts:
    39
    ok. Good to know. Thought it was the same for any windows version.
     
  34. _monoflow

    _monoflow

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

    Version 1.1 - 2016.02.04
    • - Events implemented : OnLoad, OnLoaded, OnPlay, OnPause, OnError, OnDestroy, OnPlaybackCompleted
    • - Fixed OnApplicationPaused issue. The native media player pauses now when this event is called
    • - API test is now in a seperate scene
    • - API test improved
    • - Fixed issue with debug dll reference on Windows x86_64
    • - Fixed issue with missing zip_file.jar on Android
    • - Fixed issue with seeking problem when using AwesomePlayer on Android
    • - Documentation update
    The API test is now in a seperate scene and is updated with the events. It also has some minor tweaks to prevent some confusion and the link to the blender video is updated (Old link doesn't worked on Android)

    I hope that the installation process is now flawless.
     
    mimminito likes this.
  35. VISIONSBOX

    VISIONSBOX

    Joined:
    Nov 7, 2014
    Posts:
    14
    I'm trying your demo to determine if I could use this for an application intended for iOS use on iPads and on Windows machine running with a touchscreen attached. I develop under Mac OS X (because iOS is a target platform). Unfortunately I wasn't able to run the example in your demo. In the editor I get only "EntryPointNotFoundException: Update Callbacks" in the exported project under Windows it doesn't show up either (but that is maybe because it's Windows 7). Any ideas how to fix this issue?
     
  36. joaopaul

    joaopaul

    Joined:
    Feb 1, 2016
    Posts:
    39
    Found the issue... some meta data was in thew way and Unity couldn't import the new dll...

    Just restarted Unity and before opening any scene I re-imported the package
     
    Last edited: Feb 5, 2016
  37. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Windows 7 is not supported ! And for OSX you have to publish with x86_64 architecture.
     
  38. jeroenvdv

    jeroenvdv

    Joined:
    Oct 25, 2010
    Posts:
    52
    - Where is the playback-rate property? ;)
    - Do you consider implementing some GPU accelerated (DXT-frame-format) codec like HAP? Would make playing multiple HD movies at the same time a lot easier.. :)
     
  39. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Thanks for reminding me. Playback-rate will come in the next release.
    Don't know if the playback performance of HAP is better than H264. H264 also use Hardware acceleration. The problem with HAP is that there seems to be no Media Foundation implementation only Direct Show or Quicktime. At the moment i don't see a realistic chance for HAP support.(If you have any useful information about HAP you can sent me the info)
     
  40. VISIONSBOX

    VISIONSBOX

    Joined:
    Nov 7, 2014
    Posts:
    14
    Too bad. Is that going to stay that way? You mentioned above that it may be possible to support Windows 7. It is nearly impossible to publish a Windows Executable without Windows 7 support.
     
  41. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    I try my best to get a Windows 7 version.
     
  42. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    Has the demo version been updated with the latest additions? We are considering this as an alternate solution as it has editor playback.
     
  43. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Demo has the latest additions.
     
    mimminito likes this.
  44. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    Thanks. Giving it a go now. One event that would be handy (just had to add it in myself) is an OnInit event. Call this once your Start method have finished, so we can auto load a video when you are done with your processing.
     
  45. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    Also, have you tested this with a GearVR? Im having issues with this right now, doesnt seem to load the video.
     
  46. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    I don't have a GearVR. Did you tested it on the platform without any VR stuff? (Just to be sure that it is not a codec problem). And did you hear any audio?
     
  47. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    Ive got it working, it seems to be an issue with the MPMP not being ready yet to call the "Load" method. Could we have a callback for this? So once the plugin is ready for us to start calling its methods you fire an event we can listen to?
     
    RicardoViana likes this.
  48. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Did you implemented your custom OnInit method at the end of the Start method? Perhaps it is useful to let there on frame delay. As i implemented the Start method as IEnumerator you could write at the end of the Start method this:
    Code (CSharp):
    1.  IEnumerator Start(){
    2. ....
    3. yield return new WaitForEndOfFrame();
    4.  if (OnInit != null) OnInit(this);
    5.  yield break;
    6. }
    (I want to implement this for the next version. Let me know if this fixes the loading issue for you)
     
    mimminito likes this.
  49. jeroenvdv

    jeroenvdv

    Joined:
    Oct 25, 2010
    Posts:
    52
    Great! Is the YUV > RGB (for most movies) conversion done via GPU (in video engine, or plugin or via shader in Unity3D)?

    HAP makes it possible to "force" GPU decoding (of up to 8K movies) instead of letting the system decide what it's up to today :) Also, using native GPU texture format (DXT) as frame format, slightly compressed using Snappy, makes frame upload to the GPU extremely efficient; No conversion necessary, it's already compressed in the right format for the GPU in the file so it skips decoding the videofile-frame-format into "raw" data, uploading raw data, and re-encoding into DXT in the GPU again.

    Maybe check out this post?
    http://catflier.blogspot.nl/2014/10/hap-attack-and-quicktime-fun.html
     
  50. _monoflow

    _monoflow

    Joined:
    Mar 26, 2014
    Posts:
    271
    Thanks for the link.