Search Unity

[ OSX Video Texture Pro ] - Improved QTKit/Quicktime video player for MacOSX

Discussion in 'Assets and Asset Store' started by brianchasalow, Jan 3, 2012.

  1. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    208
    oh. I guess I didn't release that one. no matter:
    Code (CSharp):
    1.  
    2. Shader "Unlit/Flipped" {
    3. Properties {
    4.     _MainTex ("MainTex", 2D) = "white" { }
    5.  
    6. }
    7. SubShader {
    8.     Pass {
    9.  
    10. CGPROGRAM
    11. #pragma vertex vert
    12. #pragma fragment frag
    13.  
    14. #include "UnityCG.cginc"
    15.  
    16. sampler2D _MainTex;
    17. sampler2D _MainTex2;
    18.  
    19. struct v2f {
    20.     float4  pos : SV_POSITION;
    21.     float2  uv : TEXCOORD0;
    22. };
    23.  
    24. float4 _MainTex_ST;
    25.  
    26. v2f vert (appdata_base v)
    27. {
    28.     v2f o;
    29.     o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
    30.     v.texcoord.y = 1.0 - v.texcoord.y;
    31.     v.texcoord.x = 1.0 - v.texcoord.x;
    32.     o.uv = TRANSFORM_TEX (v.texcoord, _MainTex);
    33.     return o;
    34. }
    35.  
    36. half4 frag (v2f i) : COLOR
    37. {
    38.     return tex2D (_MainTex, i.uv);
    39.  
    40. }
    41. ENDCG
    42.  
    43.     }
    44. }
    45. Fallback "VertexLit"
    46. }
     
  2. niall1111

    niall1111

    Joined:
    Nov 29, 2013
    Posts:
    14
    Bingo bango! Thanks man, that works like a charm!
     
  3. winnertakesteve

    winnertakesteve

    Joined:
    May 9, 2013
    Posts:
    3
    hey,

    i was just giving this plugin a test drive, seems to work great out of the box using the vtp demo scene, but as soon as i switch my build environment from OS X to iOS, running in the editor just plays a black frame. interestingly it does seem to properly extract the dimensions of the video to resize the playback surface, so it is finding the video at least. is there any obvious noob mistake i'm making?
     
  4. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    208
    Do you own a license for iOS Pro?
     
    Last edited: Feb 24, 2015
    winnertakesteve likes this.
  5. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    208
    Public Service Announcement: 4.6.3 force-enables Metal by default. This breaks VTP til I update it. For now, use open gl es 2.0 or open gl es 3.0 mode instead of Automatic or Metal.
     
    niall1111 likes this.
  6. winnertakesteve

    winnertakesteve

    Joined:
    May 9, 2013
    Posts:
    3
    ah i bet that would be it... i'll have to see if anyone else at my office has that set up. thanks for the heads up!
     
  7. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    Any timescales on when you think you will be able to support Metal (so we can use the auto option)?
     
  8. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    208
    nope, no timeframe, sorry. in the middle of a project that requires a lot of my attention at the moment- and metal support in Unity is pretty buggy at the moment, kind of a shame they made it automatic already.
     
  9. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    No worries. We are going to carry on using 4.6.2 for now, will update when we can.
     
  10. warpvr

    warpvr

    Joined:
    Dec 17, 2014
    Posts:
    14
    Hi All,

    I just updated my trial version of Unity iOS pro to a full version of Unity iOS pro. Suddenly with the new license my video on my iPhone 5c start juddering. This only happens when the video start running if I walk trough the box collider. The strange thing is that with the trial version of Unity iOS Pro this did not happen.

    Does anyone have any suggestion how to stop the juddering of my video's on the iPhone. If more information is needed I can also provide an example video of before 'with trial iOS pro license' and after 'with iOS pro license'.

    For now here is the before video (I recorded it on my computer but this is also how it works on my iPhone 5c with the trial license):
    http://we.tl/2LLLq9ccUR

    ps
    Just a quick check if I am in the right thread, I am using this plugin:

    Video Texture Pro 2.0
    https://www.assetstore.unity3d.com/en/#!/content/2575

    Little update since I wrote this:

    It seems that my CPU when playing a movie is 70% when I use the Trial iOS license. And when I switch to the iOS pro license the CPU changes to 97% . This might cause the problem. However I cannot yet find out how this happens (and it seems strange to me that switching a license changes things).
     
    Last edited: Feb 28, 2015
  11. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    208
    What backingType are you using? and what are the resolution of the videos you're playing?

    Also, if it only happens when you walk through the collider, sounds like you might have an issue with your collision layers and something's getting touched that shouldn't be?

     
  12. warpvr

    warpvr

    Joined:
    Dec 17, 2014
    Posts:
    14
    Thanks for your quick answer.

    The video is: 428 x 240 and in m4v format (and size= 7.1 MB)

    It also happens when I turn off the collider and just let the video play.

    I am not sure where/how I can view/set/change the backingType. I did see your screenshot on the previous page but that looks different from my view. I only have the MovieTexture script attached on my object.

    Also see attached a screenshot
     

    Attached Files:

  13. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    208
    Take another look at the screenshot from the previous page that i posted. It shows you how to switch into the debug view.

     
  14. warpvr

    warpvr

    Joined:
    Dec 17, 2014
    Posts:
    14
    Thank you so much. I learn everyday. This definitely made my video run smoothly again in the app.
     
  15. mr-sambarlow

    mr-sambarlow

    Joined:
    Nov 11, 2014
    Posts:
    36
    Hi Brian,
    Got round to setting this up. Have it working perfectly on OSX, but getting stuck on IOS. AVPlayer can't find my files...

    On OSX I'm doing this:

    var myVideoPath : String = "file://" + Application.streamingAssetsPath + "/D"+movieID+".mov";
    videoTextureScript.resizeVideoPaths(1);
    videoTextureScript.videoPaths[0] = myVideoPath;
    videoTextureScript.load();

    (This is the same path I was sending to the Unity movie player previously). So this works on OSX, but on IOS I get an error from AVPlayer saying it can't find the file or URL:

    Failure: Player Item status is AVPlayerItemStatusFailed with error: Error Domain=NSURLErrorDomain Code=-1100 "The requested URL was not found on this server." UserInfo=0x1918a720 {NSUnderlyingError=0x1918ac30 "The operation couldn’t be completed. No such file or directory", NSLocalizedDescription=The requested URL was not found on this server.}

    How should I pass the path for the movie on IOS? Am I doing something stupid? Any help appreciated!
     
  16. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    208
    don't use file:// , maybe?
     
  17. mr-sambarlow

    mr-sambarlow

    Joined:
    Nov 11, 2014
    Posts:
    36
    Yes, that worked! Thanks so much -- VTP is doing everything I kind of expected Unity to do out the box, great stuff.
     
  18. warpvr

    warpvr

    Joined:
    Dec 17, 2014
    Posts:
    14
    I am testing VTP for Unity 5 and I seem to only get the sound. Could this be because I am doing something wrong, or is VTP not supported yet on Unity 5?

    Looking forward to your answer :)

    ps
    VTP is the best plugin I know. And I am amazed that Unity does not offer this themselves! So thumbs up!
     
  19. niall1111

    niall1111

    Joined:
    Nov 29, 2013
    Posts:
    14
    rijkens, you probably have metal turned on by default with Unity 5. as mentioned by Brian above, VTP doesn't have metal support just yet.
     
    brianchasalow likes this.
  20. warpvr

    warpvr

    Joined:
    Dec 17, 2014
    Posts:
    14
    Thanks works like a charm :)
     
  21. warpvr

    warpvr

    Joined:
    Dec 17, 2014
    Posts:
    14
    Hi all,

    So I got this plugin to work on iPhone & iPad so that's great. Now I would like to see if I can get it to work on Android phones (or should I use this plugin: https://www.assetstore.unity3d.com/en/#!/content/10032).

    Is this possible and if so, what settings should I use?

    Thanks for the answer!

    ps
    Check out my website: http://vrexpositie.nl to see what I am working on :)
     
  22. 53B45

    53B45

    Joined:
    Sep 26, 2013
    Posts:
    6
    Hi, first I wanna thank you for this awesome plugin it is really helpful, but I'm having a bad time since I update to Unity 4.6.3, I have the pro license, but the xCode give me this error when I tried to export to iOS:
    "Undefined symbols for architecture arm64:"
    "_getVideoRotationAngle"
    "_getAspectHeight"
    "_getTextureHeight"
    .
    .
    and so

    I already changed my graphics API to Open GL ES 2.0 and I'm using IL2CPP, I also add the llibc++.dylib
     
  23. kznatt

    kznatt

    Joined:
    Sep 19, 2014
    Posts:
    5
    Has the plug-in been removed from the asset-store? I was trying to download it and it's gone.
     
  24. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    208
  25. 53B45

    53B45

    Joined:
    Sep 26, 2013
    Posts:
    6

    Attached Files:

  26. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    I am also getting errors with 64 bit compatibility. As its been pulled, I dont think there will be support for this, which is going to cause huge issues for our projects going forward...
     
  27. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    @brianchasalow , could you confirm if it is 64bit enabled? If its not, would save me a lot of time trying to work out whats wrong...
     
  28. mr-sambarlow

    mr-sambarlow

    Joined:
    Nov 11, 2014
    Posts:
    36
    Hi,
    This might not be something people can easily diagnose, but on the off chance...
    Last week I had VTP running like a dream on Mac and iOS. This week, after a few incremental changes to bits and pieces, I've started to see issues crop up in standalone builds. Everything runs fine in the editor, but when run

    - as an OSX standalone: starting a video, the audio starts up fine but there's a 1 second lag before the visuals appear
    - as an iOS standalone: the video starts straight away but there's some noticeable lag between the visuals and audio

    I'm confused as to why this just started happening as I can't see what I've changed that might have caused it. There's a chance this isn't to do with VTP at all, but just in case I've done something stupid that you can all guess at, thought I'd seek help here.
     
  29. mr-sambarlow

    mr-sambarlow

    Joined:
    Nov 11, 2014
    Posts:
    36
    I'm still wrestling with this problem.

    Whilst everything runs smoothly in the editor, in my OSX standalone build I'm getting a lag/stall on playing a new movie of about 1-2s. Once a movie has been played, if I re-play it immediately it will play properly. The stall isn't just a delay in showing the movie, it actually skips the initial second.

    Example here:



    I'm waiting for IsVideoLoaded before allowing players to push play. All my movies are located in the StreamingAssets folder. Any suggestions?

    --Sam
     
  30. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    We try to cache/prep the video by playing and then pausing immediately inside an Awake method. This seems to have helped us.
     
  31. mr-sambarlow

    mr-sambarlow

    Joined:
    Nov 11, 2014
    Posts:
    36
    Yeah, that's what I was doing when I was using the unity movietexture. But with VTP it plays by default, and .load() ing it and then setting it to pause seemed to be the equivalent? Or am I missing a step? In the editor this is flawless -- that's the frustrating part -- I can probably chuck in a short loading icon, but that wasn't necessary with the Unity movieplayer and doesn't seem to be when I'm running VTP in the editor...
     
  32. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    Apologies, I thought this was referring to another asset. With VTP we have not had this issue, but caching it shouldnt harm. You can infact stop it auto playing by pressing the "Play/Pause" button in the editor of the VideoTexture component. You can then manage the playback yourself.
     
  33. mr-sambarlow

    mr-sambarlow

    Joined:
    Nov 11, 2014
    Posts:
    36
    Yeah, I'm running it from a script so I'm unpausing when it's ready, always after it's triggered VideoTextureLoaded(). Just checking it on iOS and still the same problem there: although the videos are loaded in time, the audio is slightly out of sync. The videos are all AAC, H.264 and they're low res (640x480) so I'm assuming they shouldn't be difficult to play.
     
  34. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    I just use Handbrake to encode our videos, output as M4V at around 1280x720 and ive not had any issues recently. Which Unity version is this again?
     
  35. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    208
    Can you show me the script you're using to load the movies? Thanks,
    Brian
     
  36. mr-sambarlow

    mr-sambarlow

    Joined:
    Nov 11, 2014
    Posts:
    36
    Thanks Brian. I load the movie here--

    Code (JavaScript):
    1.     moviePlaying = false;
    2.     movieLoaded = false;
    3.     moviePlayerRawImage.gameObject.SetActive(false);
    4.          
    5.     videoTextureScript = gameObject.AddComponent(VideoTexture);
    6.      
    7.         var myVideoPath : String = Application.streamingAssetsPath + "/D"+myMovieID+".m4v";
    8.      
    9.         videoTextureScript.resizeVideoPaths(1);
    10.         videoTextureScript.videoPaths[0] = myVideoPath;
    11.         videoTextureScript.load();
    12.      
    13.         videoTextureScript.IsPaused = true;
    14.         videoTextureScript.VideoVolume = 1.0f;
    15.         videoTextureScript.LoopType = VideoTexture.VideoLoopType.PLAY_VIDEO_AND_STOP;
    16.  
    Then set the texture up here--

    Code (Javascript):
    1.  
    2. functionVideoTextureLoaded() {
    3.     moviePlayerRawImage.texture = videoTextureScript.RenderTex;
    4.     movieLoaded = true;
    5. }
    6.  
    When the player clicks the play button, this happens--

    Code (Javascript):
    1.  
    2.  
    3. function PlayTheVideo () {
    4.     videoTextureScript.IsPaused = false;
    5.     moviePlayerRawImage.gameObject.SetActive(true);
    6.     moviePlaying = true;
    7. }
    8.  
    If I run it in the editor, it's essentially instant--



    Cheers
    --Sam
     
  37. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    208
    you're effectively loading it twice, because load() is called in Start().

    right now, you're :1) disabling the gameobject, 2) calling load, waiting for whatever, 3) setting the gameobject active, which calls load AGAIN in Start() because it hasn't been started yet...

    If i were you I'd just load it paused, (but don't disable the gameobject),set the texture a black texture while it loads, and finally tell it to play when it's ready- then assign the RenderTex wherever it needs to go.
     
  38. mr-sambarlow

    mr-sambarlow

    Joined:
    Nov 11, 2014
    Posts:
    36
    Thanks Bryan. NB: In that example I have the VideoTexture on a separate object, it's only the Raw Image that gets hidden.

    As recommended, I tried waiting until the player hits play to load the texture, with a black screen until the VideoTextureLoaded() happens. Again, there's a big difference between the editor and the standalone. In some cases the standalone starts playing audio in the background before the video is turned on, but in all cases it takes much longer to get started.

    Editor


    Standalone


    Is it to be expected that a standalone build should have much longer seek times? Is there something in the way my files are organized? (there's 271 short movie files in the Streaming Assets directory). I'm running Unity 4.6.3 on OSX 10.10.2.
     
  39. mr-sambarlow

    mr-sambarlow

    Joined:
    Nov 11, 2014
    Posts:
    36
    I'm continuing to try and get to the bottom of this as it's about the only thing between me and my game's Beta!

    To rule out anything weird in my scene, I've created the simplest scene possible -- just a plane with this script on it and the demo movie file from the VTP download:

    Code (JavaScript):
    1. #pragma strict
    2.  
    3. import UnityEngine.UI;
    4.  
    5. public var videoTextureScript : VideoTexture;
    6. public var timeFire : float;
    7. public var fired : boolean = false;
    8.  
    9. function Start () {
    10.  
    11.     timeFire = Time.time + 3.0f;
    12.  
    13. }
    14.  
    15. function Update () {
    16.     if (Time.time > timeFire && fired==false) {
    17.         PlayTheVideo();
    18.         fired=true;
    19.     }
    20. }
    21.  
    22. function PlayTheVideo () {
    23.          
    24.         videoTextureScript = gameObject.AddComponent(VideoTexture);
    25.      
    26.         var myVideoPath : String = Application.streamingAssetsPath + "/demo.m4v";
    27.      
    28.      
    29.         videoTextureScript.resizeVideoPaths(1);
    30.         videoTextureScript.videoPaths[0] = myVideoPath;
    31.      
    32.         videoTextureScript.IsPaused = false;
    33.         videoTextureScript.VideoVolume = 1.0f;
    34.         videoTextureScript.LoopType = VideoTexture.VideoLoopType.PLAY_VIDEO_AND_STOP;
    35.  
    36. }
    37.  
    When I do this I see the 1+ second lag in the standalone build.



    (When this is happening with my movies I can hear the sound starting up, so it's as if the movie is playing as it should but there's some kind of snarl up with getting the video to the texture?)

    --Sam
     
  40. nikokoneko

    nikokoneko

    Joined:
    Feb 20, 2015
    Posts:
    35
    Hi, can anybody please confirm if the plugin is iOS 64bit enabled?
     
  41. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    We are using VTP with Unity 4.6.3 + IL2CPP just fine.
     
  42. 53B45

    53B45

    Joined:
    Sep 26, 2013
    Posts:
    6
    Hi mimminito, I can build with Mono (2.x) and Open GL ES 2.0 without problem, but when I change to IL2CPP I get this warning on the Xcode:

    ld: warning: ignoring file /Users/..../MovieTexture_01-04-15_0949_64Bits/Libraries/libVTPAVFMobile.a, missing required architecture arm64 in file /Users/..../MovieTexture_01-04-15_0949_64Bits/Libraries/libVTPAVFMobile.a (2 slices)
    And 29 errors of missing reference, could you please help me?
     
  43. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    Have you tried this in a project on its own, without any other plugins? We found that various other plugins would cause issues, so had to go through and ensure everything played nicely together.

    We use Unity 4.6.3, IL2CPP, Force OpenGL 2.0 and select Universal in the player settings.
     
  44. 53B45

    53B45

    Joined:
    Sep 26, 2013
    Posts:
    6
    Thanks for answering, yeah that's exactly what I'm doing, I created a new project and import the assets from the unityPackage, also using Unity 4.6.3, IL2CPP, Force OpenGL 2.0 and select Universal in the player settings.
     
  45. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    And it still doesnt work? Hmm thats very strange. I will see if I can test this in the morning. All depends which version of VTP you are using, if you didnt have the latest version before it was pulled, it could be the reason...
     
  46. 53B45

    53B45

    Joined:
    Sep 26, 2013
    Posts:
    6
    mmm you may be right, I have the 2.1.8 version, which version do you have?
     
  47. ChimeraSW

    ChimeraSW

    Joined:
    Jul 24, 2013
    Posts:
    28
    Is this still available on the Asset store? I cannot seem to find it.
     
  48. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    No, if you read half way up this page its been taken down.
     
  49. ChimeraSW

    ChimeraSW

    Joined:
    Jul 24, 2013
    Posts:
    28
    Thanks, I see it now. That sucks.
     
  50. cooli2012

    cooli2012

    Joined:
    Oct 25, 2012
    Posts:
    3