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:
    201
    also, try vt.VideoVolume = .01 not .2 -- volume controls are finnicky on iOS with regards to how much volume difference is audible.

    edit: I looked into it, and I can't reproduce the issue you're having, when I use vt.VideoVolume = 0.01f;
     
    Last edited: Jan 24, 2014
  2. SeTHBeaRzz

    SeTHBeaRzz

    Joined:
    Jan 8, 2014
    Posts:
    35
    im using Video Texture Pro 2.0.4

    I've tried vt.VideoVolume = 0.01f;
    but the result I've got is the same, the video's volume on ios device is still at 100% volume
     
  3. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    201
    update your VTP to 2.1.3 from the asset store. That feature wasn't added until 2.1.0.
     
  4. SeTHBeaRzz

    SeTHBeaRzz

    Joined:
    Jan 8, 2014
    Posts:
    35
    I've updated to 2.1.3 for VTP
    but when I build for xcode, i received Apple Mach-O Linker Error.

    any ideas?
     
  5. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    201
    I totally apologize. That is my fault- I uploaded a broken iOS version to the asset store. Fixed now -- it was really dumb. I kept testing against my local copy on my computer, which works just fine! But, I had changed 1 setting in the project file before I compiled it for the asset store... oops.
    Thanks for catching that.
     
    Last edited: Jan 29, 2014
  6. SeTHBeaRzz

    SeTHBeaRzz

    Joined:
    Jan 8, 2014
    Posts:
    35
    thanks for fixing it on such short notice. XD
    keep up the good work~!
     
  7. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    201
    the fixed version should be up on the asset store now, finally.
     
  8. arrast

    arrast

    Joined:
    Mar 18, 2012
    Posts:
    4
    Great job with this plugin!

    I wanted to ask you something...
    Is there a limit on the resolution of the video? I've been trying to play a video with a resolution bigger than 1920 x 1080 and it always crashes...
     
  9. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    201
    shouldn't be. is this iOS or OSX? and what codec are you using- h264, prores, etc?
     
  10. arrast

    arrast

    Joined:
    Mar 18, 2012
    Posts:
    4
    I am using iOS, and my videos are in h264.
    Thanks!
     
  11. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    201
    The iOS H264 decoder has a limited bandwidth / resolution maximum. I think you are probably hitting it at 1080p. Osx doesn't suffer from the same hardware limitations obviously.
     
  12. AdrienJJ

    AdrienJJ

    Joined:
    May 21, 2013
    Posts:
    2
    Hi Brian,

    I'm trying to play a 720p video in the sample scene and this works fine on all supported iPhones except for the iPhone 4. There the video plays at ~ 1 fps while the audio plays normally. While according to the specs of the iPhone it is supposed to be able to play 720p H264 video. What could be the problem?
     
    Last edited: Feb 13, 2014
  13. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    201
    unsure, as i don't have an iphone4 to test on, but it may be that the method in which i'm playing back videos is too texture-intensive for an iphone 4? this is the 4, not the 4s, i presume- which has 7x less graphics capability than the 4s. Let me ask- do smaller videos play back ok on the 4? or is it only when you try to play a 720p video?
     
  14. AdrienJJ

    AdrienJJ

    Joined:
    May 21, 2013
    Posts:
    2
    Yes, the small demo video provided with the test scene runs fine. Naïvely I thought the video was being hardware decoded and the pixel data in the video memory simply bound to a Unity Texture without needing to copy the pixel data frame by frame, but I'm probably wrong?

    Thanks for the quick reply and great plugin :)
     
    Last edited: Feb 13, 2014
  15. Yalfbal

    Yalfbal

    Joined:
    Nov 20, 2012
    Posts:
    23
    I had the same problem. Try to encode the video as a .mov with the "Photo - JPEG" codec, this works fine in iPhone 4 too.
    My problem now is that this video is too heavy for streaming, I tried to convert the .mov to .ogg like Unity does, but i cant play these oggs with the plugin -> black screen. Am i doing something wrong?
     
  16. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    201
    Adrien, Yalfbal- unfortunately for us all, Unity's texture support is such that I cannot do it as efficiently as if they built in video player support directly. What is going on behind the scenes:

    A frame is decoded, (1 texture, at movie rez) in kCVPixelFormatType_420YpCbCr8BiPlanarFullRange format, with methods like CVOpenGLESTextureCacheCreateTextureFromImage. This is fast.
    A Unity-texture is created, if necessary (1 texture, at movie rez). This is dumb.
    An FBO is bound to draw, (1 texture, at screen rez, i think) and the movie frame is drawn _into_ the unity texture right-side up. This is also dumb.

    So, it's as fast as is technically currently possible with Unity's plugin architecture.
    But, this means that we're wasting almost 2.5x texture memory for each video decoded. I have been complaining about this overuse of texture memory in video plugins for about 4 years since I gave a talk at Unite in 2010.

    Now, there exists a new API- CreateExternalTexture, and UpdateExternalTexture(), that may improve performance and remove the need for the second two aforementioned texture allocations. Unfortunately, these do not work on desktop, and have several bugs that I've reported. Unity really needs to add support for RenderTextures to Create/UpdateExternalTexture, so that this can work properly on desktop.
    If you want to see this video player work better on iPhone 4, bug Unity about supporting CreateExternalTexture/UpdateExternalTexture for RenderTextures.

    I will look into if it is possible to support Create/UpdateExternalTexture solely on iOS for now. Edit: I have completed this, see below.
     
    Last edited: Feb 16, 2014
  17. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    201
    Ok. I have an update to this- I was able to get CreateExternalTexture/UpdateExternalTexture working on iOS, as a bit of a hidden option.I'm going to test it a bit more, then I'd like it if you could test it as well, to see if it improves performance on iphone 4 and similar devices. There are a few caveats, though-

    1) Your texture will be flipped upside down in this mode. You'll have to manage this either on the transform of your gameObject, or in a shader. Either should be trivial.

    2) We're decoding to RGBA instead of YUV internally, now (this change shouldn't really affect you)- and I would be surprised if it's noticeably slower on an iphone 4. I included support for FASTPATH_YUV, but you probably shouldn't touch it as it requires writing shader code to do the YUV2RGB conversion, and handling 2 textures (Y +UV) instead of just the 1 movie texture.

    to enable it, either-
    turn on Debug mode in the inspector and set backingType to IOSONLY_FASTPATH_RGBA,

    or

    set it from script before you call load(), by doing the following:
    VideoTexture vt = GetComponent<VideoTexture>();
    vt.backingType = VideoTextureBackingType.IOSONLY_FASTPATH_RGBA;
     
    Last edited: Feb 16, 2014
  18. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    201
    Adrien, Yalfbal, please test this new beta version with the video decoding mechanism described above, at www.chasalow.com/VTP2.1.6beta.zip

    you'll know for sure it's in the right video decoding mode because when you load it on your iOS device, your texture will appear upside down. I should mention that this API is subject to change/be renamed as I finalize how to handle this on iOS. Thanks for your help testing,
    Brian
     
    Last edited: Feb 16, 2014
  19. Yalfbal

    Yalfbal

    Joined:
    Nov 20, 2012
    Posts:
    23
    Hi Brian,

    This update improves a lot the performance on iphone 4!

    Thanks you so much, it is an amazing plugin with an amazing support.
     
  20. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    201
    That's great to hear. Thanks for testing,
    B
     
  21. Yalfbal

    Yalfbal

    Joined:
    Nov 20, 2012
    Posts:
    23
    Hi Brian,

    is there any way to get the percentage of the video already downloaded in streaming mode?
     
  22. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    201
  23. venkatesh09101990

    venkatesh09101990

    Joined:
    Feb 26, 2014
    Posts:
    5
    Hi Brian,

    i downloaded the plugin,the video is displaying in pc,mac standalone in unity editor but the video is not displaying in ipad,iphone standalone in unity editor....iam using unity 4.3.4 pro What could be the problem?
     
  24. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    201
    Are you using iOS Pro?
     
  25. venkatesh09101990

    venkatesh09101990

    Joined:
    Feb 26, 2014
    Posts:
    5
  26. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    201
    That could be it, but i'm not sure. Works fine on my end...
    Do you get any errors? can you paste your console log? Sort of trying to debug blind here.

    edit: the issue was not having iOS Pro.
     
    Last edited: Mar 4, 2014
  27. venkatesh09101990

    venkatesh09101990

    Joined:
    Feb 26, 2014
    Posts:
    5
    $pc image.png
    pc standalone screenshot $ios image.png ios standalone screenshot
     
  28. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    201
    I need to see the console log.
     
  29. venkatesh09101990

    venkatesh09101990

    Joined:
    Feb 26, 2014
    Posts:
    5
    $console.png
    console screenshot
     
  30. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    201
    Thanks for the info. Hmm, in that case, I really don't know. I can only assume that it needs iOS Pro- but I have no way of testing... unless someone has a spare unity pro license (without ios pro) to lend me for testing. :p

    I just tested it on my machine that has iOS pro, and it worked fine.
     
  31. venkatesh09101990

    venkatesh09101990

    Joined:
    Feb 26, 2014
    Posts:
    5
    ok thank u for quick responses...i ll try by taking a ios pro plugin....
     
  32. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    201
    A friend has a copy of unity pro without iOS pro which I'm going to use to test later today, btw.
     
  33. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    201
    Ok. I did some testing- VTP does not function at all on iOS Free. Even if you have Unity Pro, if you switch to an iOS build platform setting, it will disable RenderTextures in the editor. Then, if you try to build, you will get this error:

    UnityException: Creating texture from native texture is PRO only.

    Complain to Unity, there's nothing I can do. Sorry!
    Brian
     
  34. SeTHBeaRzz

    SeTHBeaRzz

    Joined:
    Jan 8, 2014
    Posts:
    35
    Hey Brian,
    I was trying to utilise the JumpToVideo() but can't seem to get it working
    A Debug Log writes "Jumping to 4"
    but the Video that is playing didn't change to the specified video.

    I have currently 14 different Videos in the list.

    Currently using 2.1.4 VTP
     
    Last edited: Mar 11, 2014
  35. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    201
    upgrade to the latest version of VTP from the asset store and let me know if it still doesn't work. Does the movie at that index play regularly if you just let it play in order in the queue? is the player playing (not paused) when you try to jump?
     
  36. SeTHBeaRzz

    SeTHBeaRzz

    Joined:
    Jan 8, 2014
    Posts:
    35
    I am currently using the latest version from Asset Store,

    Does the movie at that index play regularly if you just let it play in order in the queue?
    - Yes it does, it plays normally in que.

    is the player playing (not paused) when you try to jump?
    - Yes the current video still playing when the JumpToVideo() has been called.
     
  37. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    201
    i'll take a look at it tomorrow. thanks for the details.
     
  38. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    201
    SeTHBeaRzz : I couldn't get your bug to reproduce. are you on OSX or iOS? I only tested that on desktop so far.
     
    Last edited: Mar 11, 2014
  39. SeTHBeaRzz

    SeTHBeaRzz

    Joined:
    Jan 8, 2014
    Posts:
    35
    I tried on iOS and Desktop, both produce me the same results.

    What version are you running at the moment?

    The latest version on Asset Store is 2.1.4, which is what I am using at the moment.
     
  40. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    201
    www.chasalow.com/test.png
    See attached image-

    New project, imported from asset store. loaded a folder of movies, and click these buttons to test.
    How are you trying to do it?
    Maybe you're calling it from a non-main-thread function?
     

    Attached Files:

    Last edited: Mar 12, 2014
  41. SeTHBeaRzz

    SeTHBeaRzz

    Joined:
    Jan 8, 2014
    Posts:
    35
    I'm calling the JumpToVideo() from a script of mine.
    I just tested the method you suggested, and it works when I click the buttons.

    I'm calling it with VideoTexture.JumpToVideo(3);
     
  42. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    201
    show me your code. it's jumpToVideo, not JumpToVideo, and presumably you're calling it on an instance of a class? i.e.,

    VideoTexture vt = GetComponent<VideoTexture>();
    vt.jumpToVideo(3);

    and presumably 3 <= vt.videoPaths.Length-1
     
  43. SeTHBeaRzz

    SeTHBeaRzz

    Joined:
    Jan 8, 2014
    Posts:
    35
    VideoTexture VT = GetComponent<VideoTexture>();
    VT.jumpToVideo(4);

    I have currently 5 videos in the Queue List.
     
  44. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    201
    hmm. what happens when you call that function? it continues playing the current video?
    Is there any way you could send me a small project that includes the movies you're trying to use?
     
  45. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    201
    If it works when you click the buttons, but not when you use your code, something's probably up with your code.
     
  46. SeTHBeaRzz

    SeTHBeaRzz

    Joined:
    Jan 8, 2014
    Posts:
    35
    I think figure out the problem, I was calling VT.jumpToVideo() on start().

    when I implement a KeyCode Input on the jumpToVideo() on update() it works.
    is it working as intended?
     
  47. SeTHBeaRzz

    SeTHBeaRzz

    Joined:
    Jan 8, 2014
    Posts:
    35
    My idea was to have Scene 0 as the scene that holds all the videos, and have it load specified Scene 1 to 6 when certain video in the queue has finished playing.

    That would be the timing to load specified mini games sectioned into Scene 1 to 6.
    After the Mini Games, the Scene would update an integer to PlayerPrefs and would load Scene 0 again.
    To which Scene 0 would read the integer in PlayerPrefs and jump to specified video.
     
  48. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    201
    you're basically telling it to load the first video, and then immediately jump to a different video on start. Instead, re-order the videoPaths array of strings to whatever order you want it to load in.

    Only once the videos have loaded should you be jumping around the queue list- not before.
     
  49. SeTHBeaRzz

    SeTHBeaRzz

    Joined:
    Jan 8, 2014
    Posts:
    35
    I see, thanks for your feedback.
    I'll see what I can do with it.

    Does VT.IsVideoLoaded reflects when the videos have been loaded?
     
  50. brianchasalow

    brianchasalow

    Joined:
    Jun 3, 2010
    Posts:
    201
    You should probably use the VideoTextureLoaded() callback. That method will be called on the GameObject that the VideoTexture is on, when the video has loaded. But, yes, that bool will be set to true as well.
     
unityunity