Search Unity

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. summerian

    summerian

    Joined:
    Jul 6, 2014
    Posts:
    140
    This plugin looks like what I need. What is the status on h264?
     
  2. german2209

    german2209

    Joined:
    Aug 26, 2012
    Posts:
    4
    [QUOTE=" All development and target platforms are supported, but it's meant primarily for standalone and web builds.[/QUOTE]
    Does it work for WebGL? I'm desperately looking for a WebGL capable video player.
     
  3. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
  4. HJPL

    HJPL

    Joined:
    Dec 6, 2013
    Posts:
    12
    Is there any way to adjust the playback speed?
     
  5. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193

    The frames/audiotime should be accessible, you can write your own play function in a script. At least that is what I did.

    You could approach it like this.

    frame += speed*Time.deltaTime; //Time.deltaTime will increase the value with 1 every second and speed will amplify or decrease that time.

    Of-course "frame" needs to call to the video player.

    edit: do not forget to turn of the play toggle on the player.
     
  6. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    @ShuuGames I was wondering if you had any updates for the support for the new codecs?
     
  7. Ben-Howard

    Ben-Howard

    Joined:
    Jul 21, 2014
    Posts:
    23
  8. JEulerium

    JEulerium

    Joined:
    Feb 18, 2014
    Posts:
    35
    Hi everybody. Is it working on Windows Store? What type of video I must use to make it work.
     
  9. Anima-Project

    Anima-Project

    Joined:
    Sep 25, 2014
    Posts:
    18
    Hi! We released our game with a couple of videos using this plugin. We haven't noticed any problem with 1080p videos, but one of our customers did:
    http://steamcommunity.com/app/380750/discussions/0/350532795327105842/

    We added this code:

    Code (CSharp):
    1. screenRender.material.mainTexture = this.framebuffer;
    on the OnGUI function to put the images on a Renderer since we needed to put some NGUI text (renderers) over the video based on the language of the user.

    Any idea of what could be causing this?

    Based on his description, it's like if the mainTexture stopped updating with the framebuffer, but I don't know what could be the reason for that, and only in some resolution.
     
  10. Viking-Studios

    Viking-Studios

    Joined:
    Oct 11, 2013
    Posts:
    4
    Hi, I'm currently evaluation different technologies and approaches.
    What I have:
    A large video file containing different 2D animations/clips.
    What I need:
    Jump/seek to certain points in the movie.
    Loop single animations (certain part of the movie, e.g. loop sec 2 - 5).
    Transparency.

    Can I do this with the movie player? I've already seen that it supports transparency but for the rest I'm not sure, especially about the loop feature.
     
  11. ShuuGames

    ShuuGames

    Joined:
    Jun 25, 2013
    Posts:
    188
    All of this is covered, but with transparency the options are:
    * use mpng video codec. Lossless and therefore files will be large, high cpu load, easy setup.
    * use uncompressed video. Lossless, huge files, low cpu load, easy setup.
    * use a separate track for transparency. Lossy, moderate sized file, moderate cpu load, setup needs scripting on your part.

    Since seeking is instant, looping can be done by checking time or frame number in one of your Update methods and then jumping back in time. It works smoothly.

    I guess you've figured it out by now, but for others. The file has to be in avi format, use mjpeg codec and pcm audio. Some other codecs work too, details are in this pdf
     
    Last edited: Jul 22, 2016
  12. ShuuGames

    ShuuGames

    Joined:
    Jun 25, 2013
    Posts:
    188
    Due to personal reasons I haven't been able to release any updates for this plugin for a while and support has been over email only. New winds are starting to blow from different direction and development is getting out from stalled state. It's embarrassingly late, but here's the current status:
    - mkv and webm container formats. Done
    - Vorbis audio. Done. Wanted to do Opus, but porting Vorbis was much simpler so it took priority
    - Theora video. Done. Wanted to do vp9, but again, porting Theora was much-much simpler
    - Opus and VP9 have to wait a bit
    - MP4, h264 and AAC have licensing issues and require platform support. Most notably in WebGL builds it won't work.
    - Transparent video support gets extra attention. In progress
    - Simple playback speed changing (backwards too). Done
    - RTP streaming. Has to wait a bit
    - Simple subtitles. Will do a bit later
    - Lots more, screenshots and youtube videos to come
     
    Mahdi-Jeddi likes this.
  13. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    Hi, there!

    Still enjoying your video player! In my opinion still the best one out there. There have been others claiming to render 1080-4k for 360 stereoscoping video playback. But they are all bogus as they have hundreds of driver issues and basically work nowhere.

    So I am still using your player setup for stereoscoping rendering (each camera rendering a cube-mapped cube with your player).

    As the load is heavy I have to device resolution by factors of 2, instead of 1080p, footage will be 720p, and etcetera.

    I have a question. How is higher resolution support (encoding, decoding) coming? This would greatly improve the resolution I can push to clients.

    I have read your previous post and noticed h264 is coming, great! Will there be a noticeable delay in the playback? Or any other things we might need to have in mind when using encoded formats.

    greetings
    Mark Duisters

    ps. Keep up the good work, love your asset.
     
  14. ShuuGames

    ShuuGames

    Joined:
    Jun 25, 2013
    Posts:
    188
    It's so nice to hear what you're saying :)

    The main feat of theora over mjpeg is that same quality files can be a lot smaller (because theora has P-frames aka delta-frames). Decoding speed for my theora c# port is about 4x realtime for 720p 30fps video on average i5 cpu. So I'm estimating that a good i7 should be capable of 1080p@60fps without any hickups on desktop. It doesn't sound great compared to what native code and hw accelerated drivers can do, but it's about the best what can be done in managed portable code only. But here's a big thing compared to mjpeg, theora decoding can be pushed to separate thread. Mjpeg decoding used Unity API calls so that was not possible. So for theora 4 streams of 1080p@60fps all perfectly synced should be achievable, but right now there's no threading code written for this yet, it's not first priority. Once it comes, I want to make extra sure all timings are exact and seeking works just like it does now.

    Ah, that h264. TBH, it's a pain in many ways. When it comes it will most certainly be using platform specific code with all the issues it introduces. I can talk about these all day. Where it works it'll be great, but where it doesn't there's not much I can do about it.
     
  15. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    Great, i thought so!

    Multi threaded does indeed sound nice, but I can imagine it not being a priority.

    My machine has a powerful i7. I will try out your theora recommendation! Will have a look at it soon.
    Keep up the amazing work

    greetings.
     
  16. Viking-Studios

    Viking-Studios

    Joined:
    Oct 11, 2013
    Posts:
    4
    Thx for the info. This sounds pretty good.
     
  17. cman2k

    cman2k

    Joined:
    May 24, 2016
    Posts:
    4
    Wow...transparency support is a bit of a game changer!
     
  18. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    @ShuuGames Despite calling the MoviePlayer unload function, we're noticing that the bytes for the video are not being cleaned up and garbage collected, which is causing our program to continually increase in size. Do you if there might be a bug somewhere that prevents the bytes from being released? And if you have any suggestions to determine how to fix this. It seems like this is a critical issue for us.
     
  19. chrissaam

    chrissaam

    Joined:
    Sep 15, 2016
    Posts:
    1
    The thread that is downloading the file isn't super efficient. I played with the code and with a little work it can be much more efficient. The two places that are performance bottle necks are ReadByte and the list add for each byte. If the code reads a larger input buffers and and use that to search for frame begin and end tags in that buffer it is much more efficient (10 fold at least for me).

    In the latter case I allocate a buffer of max size then download. If a start tags and an end tags are found then good those are frames. At the end of the buffer if only the start tag is found without a complete frame then the contents of the buffer get shifted left so that the last found start tag is moved to index 0 and then more bytes are downloaded into the buffer offset after the existing data. If the end tag is never found within whatever the max frame size of bytes is then the existing data is tossed as a bad frame just like your code.

    In this case the video is 250 megs and I can keep my nick pegged at %5 of a gb network card with the modifications. Prior to that I was seeing network traffick at well under %.5.

    Also I don't completely understand controlling the frame rate since the MovieStreamer seems to deal only with the frame data and tosses any meta data for the entire file. I don't think the timing is encoded in the frame itself but I could be wrong.
     
  20. Sulla__2014

    Sulla__2014

    Joined:
    Dec 14, 2013
    Posts:
    21
    Hello, and thank you for the excellent video player... I'm using it to play a cutscene video from a list of video files, sending the correct filename as a string to the Player infile. This works fine inside Unity, but in a Build no video plays (blank screen) and I get the following error in the output.log:

    NullReferenceException: Object reference not set to an instance of an object
    at MoviePlayer.ShouldRethrow (System.Exception e, MP.LoadOptions loadOptions) [0x00000] in <filename unknown>:0 at MoviePlayer.Load (System.String path, MP.LoadOptions loadOptions) [0x00000] in <filename unknown>:0 at MoviePlayer.Load (System.String path) [0x00000] in <filename unknown>:0 at MoviePlayerController.SetCutscenesToPlay (System.String which_cutscenes) [0x00000] in <filename unknown>:0 at AreaCollider_01.OnTriggerEnter (UnityEngine.Collider other) [0x00000] in <filename unknown>:0

    The play logic is: when the Player enters an enemy area collider (eg AreaCollider_01 in the last line), the correct enemy cutscene is set using a switch statement. This is sent to the Movie Player Controller script (as "SetCutscenesToPlay"), and when the encounter with the enemy is over, a MoviePlayer canvas is enabled and the correct video begins. I don't understand the first line of the error message, since this all works with no errors from within Unity.
    (Unity 5.0.0, MoviePlayer v0.1)

    Any help greatly appreciated. Thank you.
     
  21. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    @Sulla__2014
    This usually means the video is not in the correct video format. Make sure the video is in the MJPEG or MPNG avi format.
     
  22. Sulla__2014

    Sulla__2014

    Joined:
    Dec 14, 2013
    Posts:
    21
    All the videos are in mjpeg format, encoded using ffmpeg. I tried encoding one using the png option but I get a Build error "unsupported data".
     
  23. Sulla__2014

    Sulla__2014

    Joined:
    Dec 14, 2013
    Posts:
    21
    I've tried re-encoding, and using a different encoder but the video still does not play after the Build.
    Any help appreciated. Thank you.
     
  24. Sulla__2014

    Sulla__2014

    Joined:
    Dec 14, 2013
    Posts:
    21
    I changed the original file to a mov, and encoded that to mjpeg avi using avidemux, but get the same message in the output log. I ran the Build on a different PC but the problem is the same.
    Any help appreciated. Thank you.
     
  25. Lichev

    Lichev

    Joined:
    Dec 20, 2016
    Posts:
    3
    Hi, when import Playmaker actions.unitypackage i`m getting a lot of errors in console... like on attached file... help?

    I`m using Unity 5.4.1.
     

    Attached Files:

  26. Sm1l3Punk

    Sm1l3Punk

    Joined:
    Jan 10, 2017
    Posts:
    1
    Hello can i make a menu with this? like: for example: 5 buttons one with the quit, and 3 or 4 with some videos? and when i click it will just play the video that i set to play?
     
  27. scary_code_monkey

    scary_code_monkey

    Joined:
    Jun 27, 2016
    Posts:
    10
    Ditto : I have to allow the user to swap between videos, and even with prior unload, the buildup appears demonstrable.
     
  28. Wild-Factor

    Wild-Factor

    Joined:
    Oct 11, 2010
    Posts:
    607
    Can you play Mjpeg in HD ?
     
  29. neilmanuell

    neilmanuell

    Joined:
    Nov 11, 2015
    Posts:
    2
    hey @ShuuGames,

    Wondering if you can help me out.
    I want to modify the MoviePlayer so I can interpolate between adjacent frames.
    Ie frame = 11.5
    will draw frame 11 onto the given material / renderer then draw frame 12 at an alpha of 0.5 over the top.

    But I'm not sure where to start. I am presuming I should be looking in the MoviePlayerBase::Bind () method??

    cheers
     
  30. ShuuGames

    ShuuGames

    Joined:
    Jun 25, 2013
    Posts:
    188
    If you're still trying to do this then you should probably have a shader that accepts two textures and blends between them. Then places in code where texture binding and frame update happen should be modified.
     
  31. Catttdaddy

    Catttdaddy

    Joined:
    Mar 17, 2015
    Posts:
    55
    Is this Asset still working?
    I am looking for a solution to stream MJPEG into Unity from an IP Cam. Does this asset work for this purpose? Is this plugin supported any longer? Does it function?
     
  32. NostalgicTrain

    NostalgicTrain

    Joined:
    Jul 9, 2017
    Posts:
    1
    Great Asset, Great Performance, but import over 2GB .bytes file and simple click at menu, Unity is crash with overflow error. What can I do for fix this problem?
    2018-10-13 (2).png 2018-10-13 (3).png 2018-10-14.png