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

MoviePlayer for Unity (plays MJPEG)

Discussion in 'Works In Progress - Archive' started by ShuuGames, Feb 19, 2014.

?

What codec support would you like to see next?

  1. VP9 video + Opus audio (more advanced, royalty free, but less common)

    10.3%
  2. h264 video + aac audio (less advanced, licensing and patent encumbered, but very common)

    64.1%
  3. Both

    23.1%
  4. Some other, please comment

    2.6%
  1. Teadaddy

    Teadaddy

    Joined:
    Jan 26, 2015
    Posts:
    22
    wow, that is exactly what I needed!
    thanks for a great product and outstanding support. I expected a few pointers, maybe a push in the right direction, but a detailed 35 minute tutorial? very above-and-beyond.
     
  2. Teadaddy

    Teadaddy

    Joined:
    Jan 26, 2015
    Posts:
    22
    thanks again for the great asset. Perhaps you can help me with something, I am trying to figure out how to use an on click event to switch movies from movie A to movie B before playing - I am using the player controller script to bind to the framebuffer as shown in the video you directed me to. Any help would be appreciated!
     
  3. shinichi88

    shinichi88

    Joined:
    May 4, 2011
    Posts:
    80
    @ShuuGames ,
    Is me again. The movie streamer script, would it possible to get it run on Android & iOS?
    Currently is working fine on PC/ Mac / Editor.
    I got an error : System.NotSupportedException: http://ipaddress.com/videostream.cgi?user=username&pwd=password


    *not sure if this help from logcat
    12-23 19:13:34.539 799 15775 D NetlinkSocketObserver: NeighborEvent{elapsedMs=650311243, 192.168.2.1, [426C8F807C64], RTM_NEWNEIGH, NUD_PROBE}

    12-23 19:13:42.145 18291 18352 D com.facebook.a.a: Got unexpected exception: java.io.WriteAbortedException: Read an exception; java.io.NotSerializableException: org.json.JSONObject

    12-23 19:13:48.218 799 15775 D NetlinkSocketObserver: NeighborEvent{elapsedMs=650324922, 192.168.2.1, [426C8F807C64], RTM_NEWNEIGH, NUD_STALE}
     
  4. ShuuGames

    ShuuGames

    Joined:
    Jun 25, 2013
    Posts:
    188
    Just pass another movie as an argument to LoadMovie method? What is passed is set through uGUI Button on click handler. https://unity3d.com/learn/tutorials/modules/beginner/ui/ui-button
     
  5. ShuuGames

    ShuuGames

    Joined:
    Jun 25, 2013
    Posts:
    188
    Can you get full call stack for that exception? The logcat seems to be unrelated. It's not saying that the plugin doesn't support streaming on mobile devices, but some streaming subroutine is for whatever reason throwing this exception.

    Last time I checked streaming in the latest version on Android it worked. TBH I haven't tested the latest version on iOS, but almost nothing has changed in streaming code. It should work there too.

    Does the unmodified FeatureDemo scene fail to stream too?
     
  6. shinichi88

    shinichi88

    Joined:
    May 4, 2011
    Posts:
    80
    I'm back working on this after long holiday...
    Here is the full error you request :

    12-28 10:35:00.449 5662 6176 I Unity : Error Stream : System.NotSupportedException: http://ipaddress.com/videostream.cgi?user=username&pwd=password

    12-28 10:35:00.449 5662 6176 I Unity : at System.Net.WebRequest.GetCreator (System.String prefix) [0x00000] in <filename unknown>:0

    12-28 10:35:00.449 5662 6176 I Unity : at System.Net.WebRequest.Create (System.Uri requestUri) [0x00000] in <filename unknown>:0

    12-28 10:35:00.449 5662 6176 I Unity : at System.Net.WebRequest.Create (System.String requestUriString) [0x00000] in <filename unknown>:0

    12-28 10:35:00.449 5662 6176 I Unity : at MP.Net.HttpMjpegStreamer.ThreadRun (System.Object url) [0x00000] in <filename unknown>:0

    Got the exception stream from HttpMjpegStreamer.cs line 306.
    I'm using the Feature Demo unmodified.
    To be specific, it run on Editor/PC/Mac, failed on Android, iOS untested.
     
  7. shinichi88

    shinichi88

    Joined:
    May 4, 2011
    Posts:
    80
    @ShuuGames ,
    Hi, I've figure out the problem for streaming on mobile.
    It only works when the "Stripping Level" in Android Settings set to "Disabled".
    Usually I would have choose "Micro Mscorlib".
     
  8. ShuuGames

    ShuuGames

    Joined:
    Jun 25, 2013
    Posts:
    188
    I see, when stripping level is not disabled then HttpWebRequest class is not available on Android. Didn't know that, thanks for finding out.

    In web player that class wasn't available either, so in fact there is an implementation that doesn't depend on HttpWebRequest in HttpMjpegStreamer.cs. There's a chance that "Micro Mscorlib" can be used when the following #if block gets compiled in.

    Code (csharp):
    1. // In the web player build HttpWebRequest.Create will throw NotSupportedException, it doesn't happen in Editor.
    2. // Therefore we have to use lower level sockets, which is not as flexible as HttpWebRequest, but should handle
    3. // most of the cases. For example no HTTP redirects or response headers are supported in web player.
    4. #if UNITY_WEBPLAYER
     
  9. shinichi88

    shinichi88

    Joined:
    May 4, 2011
    Posts:
    80
    Hi,
    How can I use this kind of ip address?
    Code (CSharp):
    1. http://username:password@192.168.2.7:80/video/mjpg.cgi
    I try to use this on google chrome, it works. But If used on Movie Streamer, it shows

    Error Stream : System.Net.WebException: The remote server returned an error: (401) Authorization Required.
    at System.Net.HttpWebRequest.CheckFinalStatus (System.Net.WebAsyncResult result) [0x00000] in <filename unknown>:0
    at System.Net.HttpWebRequest.SetResponseData (System.Net.WebConnectionData data) [0x00000] in <filename unknown>:0
     
  10. ShuuGames

    ShuuGames

    Joined:
    Jun 25, 2013
    Posts:
    188
    Then it's no good. It doesn't fall under "most cases". The last comment in source code should be

    Code (csharp):
    1. // In the web player build HttpWebRequest.Create will throw NotSupportedException, it doesn't happen in Editor.
    2. // Therefore we have to use lower level sockets, which is not as flexible as HttpWebRequest, but should handle
    3. // most of the cases. For example no HTTP redirects, response headers and authentication are supported.
    Sorry
     
  11. praagmatic

    praagmatic

    Joined:
    Mar 23, 2014
    Posts:
    7
    I thought I'd post a link to a little howto I made using this asset. Its a live streamer for a 360 degree camera (Kodak SP360). Really simple but shows how useful/versatile this asset is. Saved me a bunch of time on the project I was working on.
     
    ShuuGames likes this.
  12. droolz

    droolz

    Joined:
    Apr 29, 2009
    Posts:
    34
    Hi ShuuGames,

    Great product, thanks...

    I managed to get passworded streams to work by modifying the underlying HttpWebRequest in HttpMjpegStreamer (passing in user (string) / password (string) / authentication (bool):

    Code (csharp):
    1.  
    2.                 var request = HttpWebRequest.Create ((string)url);
    3.                 #region Modified
    4.                 if (authentication)
    5.                 {
    6.                     String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password));
    7.                     request.Headers.Add("Authorization", "Basic " + encoded);
    8.                 }
    9.                 #endregion
    10.                 request.Timeout = (int)(timeout * 1000f);
    11.                 request.ContentType = "image/png,image/*;q=0.8,*"+"/*;q=0.5";
    12.  
    13.                 BytesReceived = 0;
    14.                 stream = request.GetResponse ().GetResponseStream ();
    15.  
    Might be of some use.

    I'm noticing that playback of the stream is much choppier / slower frame rate than the same URL viewed directly in chrome (I'm bringing in a remote, non local stream), do you know of any gotchas or ideas for improving the stream performance?

    Many thanks,

    Jules
     
  13. droolz

    droolz

    Joined:
    Apr 29, 2009
    Posts:
    34
    Hey, going through the code on VideoDecoderMjpeg.cs, I noticed that according to the docs on Texture2D.LoadImage():

    taking this out takes the fps in my test from 30-40 to well over 300, so a ten times speedup :) - getting around a 3ms decode time! It also seems to help with the smoothness of the motion, although that doesn't seem feasible as I'm not, and never have, been registering any dropped frames...

    Cheers,

    Jules
     
  14. droolz

    droolz

    Joined:
    Apr 29, 2009
    Posts:
    34
    Sorry, one more :). I'm finding the stream gamma seems very dark, much darker than the stream in Chrome - am I missing some gamma settings somewhere?

    Cheers,

    Jules
     
  15. droolz

    droolz

    Joined:
    Apr 29, 2009
    Posts:
    34
    Hi ShuuGames,

    Me again :). Please ignore the gamma issue above, this was a shader issue.

    However, I am finding that a direct comparison between watching the feed in chrome and watching it in Unity shows that unity is stuttering badly, possibly losing up to half its frames per second. It's not reporting losing any frames, but I'm not entirely sure that the Frames dropped stat is actually hooked up to the Movie Streamer?

    It also runs about 0.5 - 1 second behind in time than the chrome feed, which makes no sense to me :).

    We're using this for a video based face tracker, and video performance is completely key to it's success, are there any things you can think of to improve performance / find out why it is throwing away frames?

    Cheers,

    Jules
     
  16. Sulla__2014

    Sulla__2014

    Joined:
    Dec 14, 2013
    Posts:
    21
    Hello. Thank you for this excellent asset.
    I have a UI canvas and a list of encoded videos in a prefab to be instantiated mid-game. I have a few video-control buttons (pause, play, go to beginning, loop, etc) - but if the player does nothing then I want the videos to play in sequence through the list and then stop.
    I have the first video loaded by script and the buttons work - but what would be the best way to have the videos play in sequence?
    That is, how do I determine when the current video reaches the end, and the how do I load the next video?
    I know the no of frames in each video - could I use this to trigger the next video load? (I've tried lengthSeconds but no success).
    In your script "ScriptingDeomUI" you use a coroutine to switch videos: is this the best way?
    Or should I use OnStop? (If so, could you advise on how to use this?)

    Any advice much appreciated.
     
  17. ShuuGames

    ShuuGames

    Joined:
    Jun 25, 2013
    Posts:
    188
    I'm back and so sorry for the delay. Emails work faster for me as I miss notifications from the forum sometimes.

    First, the mjpeg streaming has always been a side feature of this plugin, the plugin is optimized for local video playback. Yet, it works and surprisingly many people are using it despite that it's designed for low framerate low resolution operation. There's no timing code in it that would smooth high framerate streams, a video frame is displayed right when the last byte of that frame arrives. If the network is good and a device is powerful enough then there shouldn't be many issues with high framerate, but there will always be out of order packets and packet retransmissions on WAN connection.

    No need to call Apply to upload texture to GPU is something new, have to check it out. Probably it's uploaded asynchronously in a separate thread now. I wonder what if that separate thread can't keep up with the pace, does it drop frames or stutter?

    About the lag. It's hard to pinpoint the issue, but it seems that network data is being buffered too much by OS before it is available in Unity. Setting sockets NoDelay option to true will eliminate the lag (tested locally), but it has negative effects on performance. There is also ReceiveBufferSize property that can be tweaked, but I think that is only relevant when not using NoDelay.
    Code (csharp):
    1. TcpClientclient=newTcpClient();
    2. client.NoDelay=true;
    3. // or tweak client.ReceiveBufferSize=1024;
    The downside to tweaking socket options is that instead of HttpWebRequest variant of code a not-so-feature-rich TcpClient variant has to be used (by default it's used only for webplayer builds. Find line "#if UNITY_WEBPLAYER" which has TcpClient code in it and change it to "#if true"). Maybe it's possible to get a socket from HttpWebRequest too using reflection or some other trick, but it's likely that it won't be portable code any more.

    The only time when frames will be dropped is when receive buffer gets full, search for MAX_BYTE_BUFFER_SIZE. It will get full if data comes in too fast and can't be processed. Increasing that buffer size won't help, but it's possible to detect those cases. Even lowering that buffer size may be a good idea, because then the amount of data that is dropped is less. Another frame drop source (if it works as I think) may come from removing texture Apply(), because async texture upload is overloaded, but that case can't be detected.

    Really, I should make a better streaming plugin :)
     
  18. ShuuGames

    ShuuGames

    Joined:
    Jun 25, 2013
    Posts:
    188
    OnStop is the way to go, it's as simple as having this C# code in a component that is attached to a game object that has MoviePlayer too. The transition from one video to another is instantaneous.

    Code (csharp):
    1. public void OnStop() {
    2.   var mp = GetComponent<MoviePlayer>();
    3.   // mp.Unload(); // required is the last Load used file path as an argument (or you'll get a memory leak)
    4.   mp.Load(nextVideo);
    5.   mp.play = true;
    6. }
    The BindFramebufferToRawImage.cs script shows another way how to register for such events.
     
  19. Sulla__2014

    Sulla__2014

    Joined:
    Dec 14, 2013
    Posts:
    21
     
  20. ShuuGames

    ShuuGames

    Joined:
    Jun 25, 2013
    Posts:
    188
    It's no problem in desktop builds and shouldn't be an issue for Editor either. Unity Editor doesn't handle large assets well (binary text assets), but usually the problems start with assets over 500MB or so.
     
  21. adroitandy

    adroitandy

    Joined:
    Nov 4, 2013
    Posts:
    30
    Hi,

    I have bought your plugin, and was testing the samples on my Mac. It seems that the CaptureWebcamToFile demo is not working, for me it says, Cant detect suitable Streamer for given url : webcam name. in the streamer class you are checking if the url begins with http. Does this not work with the built in webcam?
     
  22. ShuuGames

    ShuuGames

    Joined:
    Jun 25, 2013
    Posts:
    188
    Support for local webcam was removed a long time ago, because nobody was using it and there were issues on OSX. That particular scripting example is not valid for local webcam, but should work with remote streams (http...). Maybe you can use UnityEngine.WebCamTexture for your needs?
     
  23. metrotrak

    metrotrak

    Joined:
    Feb 14, 2016
    Posts:
    2
    @ShuuGames I just wanted to chime in on your last comment about capturing webcam textures.

    My requirements are similar: need to capture brief video + audio clip from the webcamtexture/microphone, save, and replay later. How would I achieve with your asset? I've actually had good success with WebCamTexture (it even works on IOS/Android great). I don't care if its not the highest rez nor perfect framerate. If you have advice or sample code to achieve these requirements (capture/replay from webcamtexture + mic), I will buy your asset immediately. Thanks so much!
     
  24. RD_Dev

    RD_Dev

    Joined:
    Jun 25, 2013
    Posts:
    12
    Hi.
    Is all videodata processing works on c# scripts?
    How it works on old (2010) mobile devices?
     
    Last edited: Feb 14, 2016
  25. ShuuGames

    ShuuGames

    Joined:
    Jun 25, 2013
    Posts:
    188
    The video/audio capture part has to be written by youself, there's no code in this plugin any more to do that. Once you've got that the raw data can be passed to AviRemux included in this plugin to create an avi file. There is a scripting example that shows how to use AviRemux. Basically it boils down to:
    Code (csharp):
    1. // set it up
    2. Remux remux = new AviRemux ();
    3. Stream outstream = File.OpenWrite (outfile);
    4. VideoStreamInfo vsi = ... // set framerate, resolution, codec, etc
    5. AudioStreamInfo asi = ... // set format, frequency, mono/stereo, etc
    6. remux.Init (outstream, vsi, asi);
    7.  
    8. // repeatedly add video and audio data. It expects binary data that's already encoded with audio and video codecs,
    9. // but it's not that scary as it seems, video frames can be left in uncompressed format or encoded with one method
    10. // Texture2D.EncodeToJPG. Audio can be left uncompressed too (pcm).
    11. // You have to write code that gets that data from somewhere too
    12. remux.WriteNextVideoFrame (videoBuffer, videoBytesRead);
    13. remux.WriteNextAudioSamples (audioBuffer, audioBytesRead);
    14.  
    15. // close the file, after this it can be played with this plugin
    16. remux.Shutdown ();
    Unless you're a coder I'd suggest to look for a plugin that already has capture part in it. With this you have to get dirty and at least write capture part (WebCamTexture for video, but idk about audio).
     
  26. ShuuGames

    ShuuGames

    Joined:
    Jun 25, 2013
    Posts:
    188
    Most of the CPU time is spent in platform native code that is included in Unity (decoding video frames and uploading them to GPU memory). The remaining less than 10% of CPU time is spent executing managed C#, optimized to not use heap at all (no new) while video is playing or seeked. I don't have hard data about it, but I'm guessing that 2010 year mobile devices can handle at most 360p video+audio. 2012 year Nexus 7 could play 480p video+audio. Another thing to keep in mind is that mjpeg being no-delta-frame-codec may produce files too large for mobiles, it's not an issue with short clips, but for long videos it can get pretty bad.
     
  27. metrotrak

    metrotrak

    Joined:
    Feb 14, 2016
    Posts:
    2
    @ShuuGames thank you for the pseudo code VERY MUCH. I am a coder, and that doesn't look that bad. I'm surprised someone doesn't have webcam capture and replay all in one already. I will attempt to implement, unless you think the approach you hint at is not robust, or perceive I should go with another plugin (recommendation?). One quick followup question: what function should I attach the code to? FixedUpdate()?
     
  28. ShuuGames

    ShuuGames

    Joined:
    Jun 25, 2013
    Posts:
    188
    I hope it goes well. Audio is probably more tricky to do than video. I'd put it in Update and check WebCamTexture.didUpdateThisFrame.
     
  29. ShuuGames

    ShuuGames

    Joined:
    Jun 25, 2013
    Posts:
    188
    Attention! Due to a bug in Unity audio streaming it is advised to enable preload audio (tick checkbox on MoviePlayer) on all build targets when using Unity 5.3.1 and 5.3.2. Earlier versions may be affected too, haven't tested. Without it the Unity editor crashes whenever a scene is played, stopped and played again. Bug report has been submitted, I'll link it once it's accepted.
     
    Last edited: Feb 17, 2016
  30. Keithfong

    Keithfong

    Joined:
    Jan 28, 2014
    Posts:
    3
    Hi,

    Great plugin first of all.

    I have got a working live stream from a http based off your code. However, I had to hard code the username and password as the http requires it for testing purposes. Would it be possible for you to add a username and password field for the movie streamer class?
     
  31. droolz

    droolz

    Joined:
    Apr 29, 2009
    Posts:
    34

    Hi there, if it's purely for testing, it's pretty easy to hack the HttpMjpegStreamer.cs file to allow this, see my post earlier.
     
  32. ShuuGames

    ShuuGames

    Joined:
    Jun 25, 2013
    Posts:
    188
    Alright, authentication is going into codebase and Asset Store any time soon. It's a third time in a week where people have hacked it in or requested it :)
     
  33. lappiul

    lappiul

    Joined:
    Feb 7, 2016
    Posts:
    1
    Hi,

    I see the description specifies "MovieStreamer component, that can play HTTP MJPEG streams. Requires Unity 4 PRO"

    Is that for Unity 5, PRO version is still a must for playing HTTP MJPEG streams?

    Thanks!
     
  34. ShuuGames

    ShuuGames

    Joined:
    Jun 25, 2013
    Posts:
    188
    It applies to Unity 4 only. Unity 5 Personal is enough for streaming.
     
  35. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    @ShuuGames I've been using your plugin for a while now and so far everything has been great. I was wondering if at any point you have plans to support additional video formats?

    I feel like MPEG-4 would be greatly beneficial because of its sizes, but I'm not sure how complicated the implementation would be. Currently because of my project requirements I've had to setup my own FFMPEG video converter for the artists, so they don't need Unity to produce the videos I need, but I feel as though removing the FFMPEG step would help greatly with productivity.
     
  36. ShuuGames

    ShuuGames

    Joined:
    Jun 25, 2013
    Posts:
    188
    A few days back I started to work on support for delta frame codecs. It's a big step, because with this platform native code comes in which I've avoided for portability reasons. A royalty free VP9 video codec would be the first, it's more advanced than h264 most commonly used these days in MPEG4. The very first platform to be supported is Windows standalone, but it shouldn't take long until I get OSX, Linux, Android, iOS and limited WebGL (not WebPlayer) support out. Other platforms may take a more time, because I don't have hardware to develop and test it on.
     
  37. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    @ShuuGames Ok, that's good to hear your roadmap/plans. Thanks for the update.
     
  38. DCrosby

    DCrosby

    Joined:
    Jan 13, 2013
    Posts:
    86
    I'd like to cast my vote for HLS Streams, which seem to work natively on Android / IOS, but have as of yet not found many players on Unity that know how to handle a live stream.

    The one I typically test with because it's a nice 4K Stream, is : http://sample.vodobox.net/skate_phantom_flex_4k/skate_phantom_flex_4k.m3u8

    But doesn't work in the web player, states it doesn't have rights, for cross domain permissions. Which could be due to the web player's restrictions, if this works in the asset you have another customer.
     
  39. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    @ShuuGames I noticed in the MoviePlayer Editor script you use:
    videoFrame = Mathf.RoundToInt (videoTime * framerate);

    But in the MoviePlayer Update you use:
    videoFrame = Mathf.FloorToInt(videoTime * framerate);

    Is there a reason for the discrepancy between the two? I was having rounding issues caused by me saving values with FloorToInt and was wondering if RoundToInt was perhaps more accurate when calculating the frame? Or is this just because for the editor it needs to be this way?
     
  40. ShuuGames

    ShuuGames

    Joined:
    Jun 25, 2013
    Posts:
    188
    Streaming... I don't want to get your hopes up, but every now and then I think about how to add streaming too. It's difficult to do reliably and in a cross platform way. So at first, proper modern codec support, then we'll see.

    This calculation should always be FloorToInt, thanks for pointing this out. In editor script it doesn't matter that much, because it's used for Editor preview only, but still.
     
  41. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    @ShuuGames Regarding streaming, it seems like all the major cloud services (Azure, Amazon Web Services, etc...) don't really support MJPEG for streaming. I was wondering if once you have the H.264 support, will that be streaming as well?

    Also, do you have an idea of the rough timeframe for when you'll be ready to update the plugin with H.264 or any other MP4 container?
     
  42. ShuuGames

    ShuuGames

    Joined:
    Jun 25, 2013
    Posts:
    188
    About a month to get to the first stable local playback release with new codecs up in Asset Store. For testing purposes I can give it out earlier, just ask if you already own the plugin. After a few weeks I have a unitypackage to send out.

    Once new codecs are in, the streaming isn't such a big deal any more. First bleeding edge unstable one-platform streaming code should be ready about the same time as local playback stable release. From there on, it's a few weeks at least more to get to the first stable.

    These versions are much harder to implement and test and not everything can be cross platform. No Unity 4 support either any more. So there will be a big platform x feature matrix. Each cell will show if a) it works and is tested, b) should work but not tested c) can be made to work in the future, d) can't be done or is very impractical on that platform. I'm grateful to everyone who reports back about features that should work but are not tested.

    mp4 and h264 seems like it just has to come... I'll see what I can do.
     
  43. Delaley

    Delaley

    Joined:
    Jan 19, 2016
    Posts:
    6
    Please What Video Converter did you use. I've tried all posible options. Am still getting that Unsuported PCM format.
     
  44. mhogle

    mhogle

    Joined:
    Jan 3, 2016
    Posts:
    20
    Hi there! Thanks for the great plugin. The only concern I have is the memory of the converted files by ffmpeg. I have a lot of short videos, and after converting them to avi format, they become really big (few hundreds megabytes each file). Is there any solution to this problem? I understand that the video quality is a tradeoff, but hopefully it still can be acceptable.
     
  45. ShuuGames

    ShuuGames

    Joined:
    Jun 25, 2013
    Posts:
    188
    FFMPEG is the best. The command line option for audio codec that you may want to use is "-acodec pcm_s16le". If command line is not your friend then in Unity "Window / Movie Player Tools / Movie Encoder" provides GUI frontend for FFMPEG.
     
  46. ShuuGames

    ShuuGames

    Joined:
    Jun 25, 2013
    Posts:
    188
    Look critically at required resolution and framerate of the videos. With mjpeg codec 2x framerate means 2x larger file and 2x more pixels is 2x larger file too. Downscaling a video by 20% may not reduce visual quality significantly (1080p->900p), but will make file 44% smaller.

    Really you should wait until VP9 video codec gets supported, then this issue will go away (unless instant seek and nonlinear playback are important for you). I'm working hard to get it done asap.
     
  47. mitchtheriault

    mitchtheriault

    Joined:
    Aug 4, 2013
    Posts:
    27
    Hi ShuuGames,

    Thanks for making a great asset! I'm having an issue, though. I'm making a project in Unity that randomly plays a series of video files, and with MoviePlayer's PlayMaker integration, it seemed like a good match. So, I used the "Send Random Event" function in Playmaker to randomly pick a movie to load and then play it's finished, and then pick the next movie, and so on. My project works fine in the "game" window, but when I build it (I've tried OSX and iOS) it will play for about 8-10 clips, and then it seems to stop loading movies. Do you think this is a problem with MoviePlayer, or Playmaker?

    Thanks again
    Mitch
     
  48. ShuuGames

    ShuuGames

    Joined:
    Jun 25, 2013
    Posts:
    188
    It's hard to say what can be the cause. Things you can try:
    * turn on "PlayMakerGUI / Draw active state labels" to see where the state machine gets stuck
    * see if any errors go into Unity log (messages generated by Debug.Log... and exceptions)
    * double check if all videos actually can play. If loading next video fails then Playmaker action may get stuck
     
  49. shinichi88

    shinichi88

    Joined:
    May 4, 2011
    Posts:
    80
    Hi,

    1. How can I increase the video playback speed?
    2. Can it support 4K video?
    3. I try to manually seek video frame using finger drag, but the video stuck/stop at random frame. Have any solution?

    Thanks.
     
  50. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    @ShuuGames I noticed in the profiler there is 0.7k-1.3k of garbage collection each frame on Update. Is there any fix for that to make the MoviePlayer to have less impact per frame?

    EDIT:
    I guess the realities are that this will happen for each frame that is decoded into a Texture2D. Perhaps there's a way to prevent a new Texture2D from being created each frame, but instead change a texture's pixel data every frame. I'll try to look into the source and see if there are any optimizations I can recommend.
     
    Last edited: Apr 11, 2016