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

Use of Video (eg. quicktime)

Discussion in 'Editor & General Support' started by willgoldstone, Nov 8, 2006.

  1. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    794
    Hi guys,

    have a few queries coming in from my students about the possibilities of unity - theyre trying to decide whether to utilise it for their major projects. Many plan to make narrative led games and want to know if they can somehow incorporate quicktime or video in some other format into unity. I cant say that i've seen this done or even mentioned, so I thought i'd throw the question out you folks!


    cheers,


    Will
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,773
    If Unity allows videos to be used as textures (I think I've seen it mentioned that it does) you could just put a GUITexture with the video as its material.
     
  3. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    The last I heard here on the forums was that you could use -uncompressed- quicktime as a texture, but because of overhead, you were limited to fairly short video "snippets". If you do a search of past posts you'll probably find a post discussing this.

    Personally, I'd love to see Unity add Flash video to the 2D GUI layer...
     
  4. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,773
    Flash video? What does Flash video have to do with Unity?
     
  5. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    I'm not talking about using video as a texture, but rather as a 2D element in the GUI, like an intro video (although a video texture for 3D objects would be very cool as well). A number of other game engines already support this and this request has come up for Unity a couple times in the past. Of the video codecs out there, I've found Flash Video to be the best.
     
  6. jocphone

    jocphone

    Joined:
    Jun 26, 2006
    Posts:
    32
    Yes please to Flash video on the 2D layer.

    With sound as well would be extra useful.

    Joc
     
  7. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,773

    Seriously? It may be smallish, but I've never seen flv that didn't look like garbage. Contrast Divx's stage6 to youtube - there's just no comparison.

    The ideal solution, of course, would be to allow any installed Quicktime codec. If you're worried about portability, the builder could transcode to a Unity-wide standard compression.
     
  8. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    Yes, seriously. My experience is the exact opposite. If you compare comparable filesizes, the .FLV file always looks better and plays at a higher framerate IMHO. Plus, almost everyone has the Flash plugin installed (I'm talking Windows users). Not many people have DivX installed. Probably more have Quicktime, but not all the codecs.

    The best option would be to support -everything-, then everyone would be happy. ;)
     
  9. DocSWAB

    DocSWAB

    Joined:
    Aug 28, 2006
    Posts:
    615
    The new ON2 codec for FLV in Flash 8 is really, really good. Don't know how it stacks up against DivX, but it blows Sorenson 3 away bit for bit.
     
  10. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
    It's also essential that the codec/wrapper can handle alpha channels... which a lot of these can't. I still think QuickTime is the best bet.
     
  11. AaronC

    AaronC

    Joined:
    Mar 6, 2006
    Posts:
    3,552
    Whats the go with using animated gif's?
    AC
     
  12. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,773
    For those that don't, can't the alpha be set by Unity to just 1?
     
  13. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
    Sure, if you don't need alpha channels (or they're not included in the video files you're making) Unity could set it to 1. I was just saying that for any GUI work with video files, or other effects, you absolutely need a codec that includes alpha channels. I just had a look at ON2 with Flash and it does support 8-bit alphas which is really cool, but it says it's a Flash Pro only feature which makes me think licensing issues would be involved... or just the fact that Flash Pro costs $699 could be a barrier to many.
     
  14. AaronC

    AaronC

    Joined:
    Mar 6, 2006
    Posts:
    3,552
    Dont mean to be annoying but I have often wondered about animated gif files, they too can be transparent...
    Maybe its a trick to get licensing?
    AC
     
  15. freyr

    freyr

    Joined:
    Apr 7, 2005
    Posts:
    1,148
    Gif files do not have an alpha channel. You can only specify wheter a pixel is completely opague or transparent. (So in an sense the aplha channel is only 1 bit per pixel)

    Also, animated gifs draw subsequent frames on top of the previous frames, reusing the transparency bit to indicate non-changed areas, which means that once a pixel becomes opague, it can not become transparent again in a later frame.

    The compression rate is not very good and gifs are max 8 bit per pixel (using a 256 entry color index, with one entry reserved for transparency in transparent gifs)

    So you get almost the same size (maybe around 50% size if you are lucky) as uncompressed movies at reduced color resolution with poor transparency effects.
     
  16. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    794
    Guys,

    interesting to look over this discussion, as far as I understand it from talking to peter in the irc channel unity doesnt currently support video.. so, maybe this is indeed a good time to start discussing what the best solution would be. I'm siding with quicktime on this one - definitely in agreement that flash video using on2vp6 is fantastic, but restricted to those developers using flash8, which as has been pointed out is rather expensive, whereas quicktime pro is a fraction of the price. Plus its mac native, and easy to get working on a pc, as opposed to divx which has a much tinier market share when it comes to video (if you discount illegal tv / movie downloads). Thoughts?
     
  17. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    My thinking is that whatever video solution we choose, we have to include everything necessary for it's playback into Unity (standalones or web player installer). We can't rely on users "just having Flash" or "maybe having Quicktime on windows".

    So the questions is what's the best video quality, the smallest distribution size and the best licensing scheme.
     
  18. AaronC

    AaronC

    Joined:
    Mar 6, 2006
    Posts:
    3,552
    Thanks Keli, ive been wondering about that
    AC
     
  19. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    Agreed.

    AFAIK there's a Flash SDK to allow you to integrate Flash creation and playback in your application. That's why there's so many 3rd party apps that can create Flash files.
     
  20. Cav

    Cav

    Joined:
    Aug 2, 2006
    Posts:
    93
    Following on from the above...just to clear things up;

    i understand that there is no video support at the moment...

    is there any work-arounds anyone knows of to play video 'mid-game' if you will.

    Cav.
     
  21. freyr

    freyr

    Joined:
    Apr 7, 2005
    Posts:
    1,148
    If you are using a web player, you could hide the unity player using DHTML in the embedding browser window and show a Quicktime or a Flash plugin instead. (This will not work if running in full-screen)

    In a standalone player, you could create a plugin for playing back video if you have Unity Pro. There is a sample plugin on the Unity website that shows how to upload image data to a texture object. This could be used for playing back video.
     
  22. AaronC

    AaronC

    Joined:
    Mar 6, 2006
    Posts:
    3,552
    http://forum.unity3d.com/viewtopic.php?t=3395&highlight=

    Theres a setup for moving a camera along a set of waypoints.

    In one of the earlier examples is this but you need a different material for each frame(Takes ages to setup-uses heaps of vram
    Code (csharp):
    1. // Anything declared with var outside a function is visible and can be changed in the inspector
    2. var material1 : Material;
    3. var material2 : Material;
    4. var material3 : Material;
    5.  
    6. function Update () {
    7.     // time shall repeat in the range 0 ... 1
    8.     time = Mathf.Repeat (Time.time, 1);
    9.  
    10.     // Change the material every 1/3 second
    11.     if (time < 0.33) {
    12.         renderer.sharedMaterial = material1;
    13.     }
    14.     else
    15.     {
    16.         if (time < 0.66) {
    17.             renderer.sharedMaterial = material2;
    18.         }
    19.         else {
    20.             renderer.sharedMaterial = material3;
    21.         }
    22.     }
    23. }
    and then theres this:

    http://forum.unity3d.com/viewtopic.php?t=2670&highlight=

    Keyframing the camera within Unity can get outta control. Explore these :)
    HTH
    AC
     
  23. Cav

    Cav

    Joined:
    Aug 2, 2006
    Posts:
    93
    cool thanks.

    Targos, not sure if you got what i was getting at. i want to play something like a quicktime clip or some such format. nothing too extravagant only about 5 seconds of footage.
     
  24. freyr

    freyr

    Joined:
    Apr 7, 2005
    Posts:
    1,148
    Another carzy idea is to rewrite the mpeg-1 decoding part of UC Berkely's mpeg player in C# and use Texture2D.SetPixels to display it in a texture. This solution does not require Unity Pro to work... It should even work in a web player (If you find a way to get at the mpeg data.)

    A certain Ron Breukelaar has written a mpeg player in Java, so it should be possible to do in C# as well.
     
  25. Cav

    Cav

    Joined:
    Aug 2, 2006
    Posts:
    93
    I'm not feeling that crazy today! The plugin way seems to be the best way forward for now.

    with my unfamiliarity; am i supposed to pull a frame from the movie on each iteration and apply that to the texture or is this over-complicating the matter and there is a way i can just apply the movie to the 'data' of 'glTexImage2D'?
     
  26. AaronC

    AaronC

    Joined:
    Mar 6, 2006
    Posts:
    3,552
    Cav, I had this example from an old idea.
    Sometimes when I import a package to an empty project I get this error:
    If this happens for you, restart Unity and It seems to fix itself.

    Theres no"drag compressed movie into Unity" at this stage but you can go to an embeded html page using the WWW classes. This is one way to achieve your aim:
     

    Attached Files:

  27. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203