1. All Unity Pro perpetual license customers: your special offer to subscribe is ready! Click here.
  2. We're running a survey about the usage of our graphics pipeline, help give us your feedback.
  3. Unity 5.6 beta is now available for download.
  4. Unity 5.5 is now released.
  5. Check out all the fixes for 5.5 in patch releases 1 & 2.
  6. Enter the Google Play Indie Games Contest in Europe. Read more about it here.
  7. Get prepared for the Tizen Mobile App Incentive Program! Read more about the upcoming program here.
  8. Enter the Microsoft Developer Challenge for a chance to win prizes. Read more about it here.

[Released] AVPro Video - complete video playback solution

Discussion in 'Assets and Asset Store' started by AndrewRH, Feb 12, 2016.

  1. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Messages:
    1,075
    Yes the playlist feature is coming in the next version which also has a ton of other great features :) I'm not sure when it will be ready. We plan to release a minor update soon with a few bug fixes (v1.3.5) and then we'll push for v1.4.0 which I hope will come out within 3 weeks.

    You should take a look at the SimpleController.cs script which shows you how to load different videos. Here's a script snippet which I hope helps:

    Code (CSharp):
    1. using UnityEngine;
    2. using RenderHeads.Media.AVProVideo;
    3.  
    4. class VideoSwitch
    5. {
    6.    public MediaPlayer mediaPlayer;
    7.    public string[] filenames;
    8.  
    9.    void Update()
    10.    {
    11.        // every 100 frames
    12.        if ((Time.frameCount % 100) == 0)
    13.        {
    14.            SwitchRandomVideo();
    15.        }
    16.    }
    17.    private void SwitchRandomVideo()
    18.    {
    19.       MediaPlayer.FileLocation location = MediaPlayer.FileLocation.RelativeToStreamingAssetsFolder;
    20.  
    21.        string videoFilename = filenames[Random.Random(0, filenames.Length)];
    22.  
    23.        mediaPlayer.m_AutoStart = true;
    24.        mediaPlayer.OpenVideoFromFile(location, videoFilename);
    25.      }
    26. }
     
  2. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Messages:
    1,075
    Hey,

    Well we have been experimenting and I'm glad to say we have added SOME support for timeScale now. This is still a very experimental feature and we still need to test it on other platforms to see how it works. On Windows though, with a suitably encoded video it does seem to work pretty well :) Expect this to come out in the upcoming version 1.3.5. I'm not sure whether this will fix your issues though as this is more for scrubbing time etc and not for fixing jitters.

    It sounds like your video playback is just using too much processing power. I would recommend re-encoding your video so that it takes less work to decode (things like disabling CABAC, less reference frames etc). Or if you're using Windows then you can run your app / Unity Editor with the command-line flag "-force-d3d11-no-singlethreaded" which will enable GPU acceleration.

    I hope that helps. Let me know.
     
  3. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Messages:
    1,075
    Ahhh I see!! Well then good news - the upcoming experimental support for timeScale will certainly help you. At least for Windows as this is the only platform we've tested it on so far! We also needed to do some video captures so we had to quickly add support for this :)
     
  4. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Messages:
    1,075
    Hi,

    If I were you I would consider re-encoding the MP4 videos to use less processing power while decoding.

    Or if using Windows then run your app/Unity with the command-line parameter "-force-d3d11-no-singlethreaded" which will enable GPU decoding acceleration for Windows 8 and above.

    Hope that helps,
     
  5. phileday

    phileday

    Joined:
    Feb 8, 2014
    Messages:
    50
    Hi AndrewRH
    I previously mentioned a crashing problem (Under NSC Creative) which I was getting when switching videos. I have found that this doesn't happen with my player Whirligig so I'm going to suggest in my case it isn't something to troubleshoot just yet.

    The new question I have is just relating to the next release. You mention replacing the Window AVpro with AVpro Video for windows. The only thing I'm currently missing myself between the two is the Direct Show filter support on all Windows platforms. Is this something you are still implementing? I can't move Whirligig over to using the latest plugin until that is support as it will cause problems for a lot of people not having that as an option.

    Looking forward to the next update.

    All the best

    Phil
     
  6. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Messages:
    1,075
    Hey Phil,

    We have an internal version which can force DirectShow support. This will be included in the upcoming v1.3.5 which I hope will be out by the end of this week. I've just got back from a long work trip so it's full steam ahead now for getting the new releases out.

    Thanks,
     
  7. phileday

    phileday

    Joined:
    Feb 8, 2014
    Messages:
    50
    Cheers that really good to hear. :)
     
  8. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Messages:
    1,075
    A sneak peek at some upcoming additions:

    Playback rate controls and ability to specify stereo packing format :)

    upload_2016-6-8_16-37-54.png
     
  9. phileday

    phileday

    Joined:
    Feb 8, 2014
    Messages:
    50
    Looks good, I'm particularly interested in the playback rate :)
     
  10. phileday

    phileday

    Joined:
    Feb 8, 2014
    Messages:
    50
    Hi
    I have a problem with a video file on Android. I have a 24 minute video that I'm trying to fit into a apk 2gb. I've managed to get the file down to 1800gb and it builds and goes to the Samsung s7 but then doesn't play. I've used ffmpeg to cut it in half and then it plays.

    Is there a limit to the file size of a video file on an Android device? It will play through the GearVR video player but not using AVpro. I've encoded with the same settings but different length and it seems that when it's below 1gb it works. Any ideas or advice regarding this. It would be possible to split the video into multiple parts if it turns out to be a problem.

    All the best

    Phil
     
  11. fklingler

    fklingler

    Joined:
    May 29, 2015
    Messages:
    10
    The CloseVideo() method seems not to free any memory and iOS, eventually causing a crash at the end when loading multiple videos in sequence (using CloseVideo() between each Load).

    Does anyone has stumble upon this problem?

    Thanks,

    François
     
  12. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Messages:
    1,075
    Are you loading it via Streaming Assets? Anything in Streaming Assets is zipped and has to be unzipped to play. Perhaps the GearVr player can play it because it's just a file sitting on the disk? Or did you also try just loading it form an absolute path?
     
  13. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Messages:
    1,075
    Interesting, we'll investigate this.

    Some questions to help us:
    What kinda and resoluton video are you using?
    After how many times does it crash?
    Which iOS device are you using?

    Thanks,
     
  14. phileday

    phileday

    Joined:
    Feb 8, 2014
    Messages:
    50
    I am loading it vir the StreamingAssets folder and thought that might be the case. Wasn't sure if there were any restrictions to this but information on this in my searches is all a bit vague so I'd thought I'd check with you to see if you knew of any restrictions. Looks like I might have to implement a download system as we, in truth would want to have larger video files than 2gb anyway.

    I'll let you know if I manage to find and concrete information on this.

    Cheers,

    Phil
     
  15. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Messages:
    1,075
    That would be great. We haven't used such large files on Android before but I suspect it would be better to have them external rather than in StreamingAssets for such large files. On other platforms it might be fine, but because the Android package is bundled into the APK/OBB it adds an extra step to reading out the file.
     
  16. fklingler

    fklingler

    Joined:
    May 29, 2015
    Messages:
    10
    I'm using videos of about 100MB more or less, resolution 2880x1440. I inspected the memory footprint of the app using XCode debug tools (not Instruments, but just the memory page of XCode when you debug an app), and it clearly grows without ever shrinking, ultimately closing the app when the memory footprint is too big (when there is like 30MB of RAM left on the device).
    It does so on every iOS device we tested on (iPads and iPhones, different versions)
     
  17. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Messages:
    1,075
    Thanks, we're looking into it now. I will let you know what we find.
     
  18. Tom-Goethals

    Tom-Goethals

    Joined:
    Mar 6, 2015
    Messages:
    35
    Hi Andrew,

    Got an app running on iPad Air 1. After a good 40 video plays the app crashes. It might be related to the above. Any workarrounds already? i'm calling CloseVideo() before loading the next one.
    (videos are full HD but low bitrate 2Mbs and averiging 8MB per video)

    Best regards,
    Tom
     
    Last edited: Jun 14, 2016
  19. Satari

    Satari

    Joined:
    Jan 3, 2016
    Messages:
    7
    Hello everybody,

    i'm trying to display a 4k video with 60FPS in Unity on a real 4k and 55" Screen with the demo version of the AVPro Plugin. It looks good but the video is stuttering quite a bit and you can easily recognize the stuttering.
    Now i read in your documentation that the watermark can cause some performance problems when displaying high resolution content.

    If the stuttering is really only caused by the watermark i would buy the pro version. But for my (Student) this version is quite expensive. So is there a way for me to find out if the stuttering is caused by the watermark or by any other problems?

    Here are some details to the machine i'm working on:
    Windows 10 64 Bit
    Intel Core i7-4930K CPU @ 3.40GHz 3.70 GHz
    32 GB Ram
    Nvidia GeForce GTX Titan

    I've also uploaded the original video file i'm playing and a fraps recording of the performance of the video displayed in Unity, so that you can have a better view on my problem.

    1. The original video file i want to play

    https://www.dropbox.com/s/n5mwce0euhr3o65/4k_60fps_dummy_video.mp4?dl=0

    2. The fraps recording

    https://www.dropbox.com/s/fuj6ov8188dvf7v/Unity_recording_4k_60fps_h264_dummy_video.mp4?dl=0

    Thank you in advance for your help

    Best regards,

    Satari

    PS: I'm using the "Demo_BackgroundShader"-Scene in Unity
     
    Last edited: Jun 14, 2016
  20. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Messages:
    1,075
    Hi Tom, We're looking into this now. Early indications are that it's actually happening at the OS level.. We'll keep you informed.
     
  21. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Messages:
    1,075
    Hi Satari,

    Here is an extract from an upcoming update to the FAQ in the plugin documentation:

    How can I get smoother video playback for my Windows VR app?

    This is usually caused by the video decoding taking too much CPU time. Some videos (especially highly compressed ones) require a lot of CPU time to decode each frame.

    Try launching your app/Unity with the “-force-d3d11-no-singlethreaded” command-line switch. This will enable your application to use GPU decoding which is much faster. This option is only supported on Windows 8.1 and above and when D3D11 graphics API is used.

    You could also try re-encoding your video using settings that are less demanding for the decoder. Most H.264 encoders have a ‘fast decode’ preset, or you can manually change settings such as disabling CABAC, reducing bitrate, disabling B-frames, disabling the loop (deblocking) filter etc.

    You could also try switching to another video codec that allows for less CPU intensive decoding. Codecs such as H.264 / H.265 are generally very heavy on the CPU. Hap is an extremely fast codec but will result in large files.

    I would recommend trying the“-force-d3d11-no-singlethreaded” option. Because you're using the trial version this mode will have another 'watermark' which is a frame shift/jitter that happens every 1-2 seconds. This is just part of the watermark and you should see the video plays much smoother.

    Also, please email us unitysupport@renderheads.com to talk about student discount.

    Thanks,
     
  22. Satari

    Satari

    Joined:
    Jan 3, 2016
    Messages:
    7
    Hi Andrew,

    first of all, thanks for your fast response. I tried your recommendation with the “-force-d3d11-no-singlethreaded” option but the displaying of the video became even worse (as you can see in the video linked below). Does this force option also work when i've already installed DirectX12?

    Fraps recording of the video played in Unity with the “-force-d3d11-no-singlethreaded” option

    https://www.dropbox.com/s/qczzy54an...ps_h264_dummy_video_with_force_d3d11.mp4?dl=0
     
  23. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Messages:
    1,075
    What do you mean by installed DirectX12? For this feature to work you should have your Unity Project set to D3D11 only. Does the video play smoothly in other players? The watermark does add a bit of overhead but it shouldn't be too much.

    Thanks,
     
  24. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Messages:
    1,075
    Another new feature coming in the next update: you can force DirectShow for Windows players. This will allow you to use 3rd party DirectShow codecs (such as LAV Filters) and will also enable Hap playback:

    upload_2016-6-14_18-46-54.png
     
  25. Satari

    Satari

    Joined:
    Jan 3, 2016
    Messages:
    7
    Well, i thought that D3D11 is connected to directX11 and because of that i wanted to ask if the command you told me also works when i have already installed directX12 on my system.
    Beside of that the video runs without any problems in the VLC player and the MediaPlayerClassic in fullscreen on the 4k TV-Screen. Only the windows media player has problems to play the video.

    And as you can see in the video i linked in my previous post the performance of the video is getting even worse.
     
  26. phileday

    phileday

    Joined:
    Feb 8, 2014
    Messages:
    50
    Thats the feature I want :) Will it be switchable at runtime?
     
  27. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Messages:
    1,075
    It's not switchable at run-time currently. We hope to make it a fallback as well but for now this is where it's at.
     
  28. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Messages:
    1,075
    Hi All,

    Another upcoming feature: ability to override the default audio output device. This is useful for VR device such as Rift and Vive where they have their own audio devices.
    upload_2016-6-14_22-30-51.png

    Thanks,
     
    jotamaza and kideternal like this.
  29. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Messages:
    1,075
    Hi, we're still looking at this issue. So far it seems to related to the iOS METAL rendering path. So if you switch to OpenGL graphics API (in Player Settings) it should in theory be fixed. I will let you know what else we find as we investigate more tomorrow. Thanks,
     
  30. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Messages:
    1,075
    Hi Tom, we're still looking at this issue. So far it seems to related to the iOS METAL rendering path. So if you switch to OpenGL graphics API (in Player Settings) it should in theory be fixed. I will let you know what else we find as we investigate more tomorrow. Thanks,
     
  31. Tom-Goethals

    Tom-Goethals

    Joined:
    Mar 6, 2015
    Messages:
    35
    I switched to OpenGLES2 (removed metal) and recompiled, it now has some weird rendering issues on UI stuff but also does not appear to solve the issue here. Still crashes after a good 40 plays. I'm wondering if it could be something else. All i should need to do is call CloseVideo() right? i'm not removing or re-creating any components. Just calling OpenVideoFromFile after the CloseVideo.

    Now re-compiling with OpenGLES3 as top of the list. (also removing a rogue AddListener I left somewhere)
    We need a faster Mac to compile this iOs stuff :) takes ages.
    [EDIT]

    OpenGLES3 removes the weird UI rendering but the crashes persist.
     
    Last edited: Jun 15, 2016
  32. jeroenvdv

    jeroenvdv

    Joined:
    Oct 25, 2010
    Messages:
    36
    Hi!

    Great to see those new features coming up, including HAP on Mac & Windows (all versions). Much appreciated!

    Would like to suggest (or hopefully conclude it's already there ;) )..
    You mentioned, the Windows version already supports a wider range of containers (like MOV). Would be great to be able to use MOV container with the (Quicktime) HAP codec inside, on Windows. Content creators work a lot in environments where a Quicktime MOV container with corresponding codecs is the standard. Otherwise, they have to re-render the content to your DirectShow HAP codec in another container format, and that has to be done on Windows machines.

    This would also allow the users to use the same videocontent files on both Windows & Mac versions.
     
  33. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Messages:
    1,075
    Hi Tom, I just came here to post some good news and then I read this :) Sorry you're having these troubles.

    The good news is - we found the memory leak with the Metal rendering path - it wasn't freeing the texture properly! It's being patched now.

    We ran our test of opening video + closing video on GLES2+3 for over 1000 iterations without any crash or memory increase. We must be doing something different to you. Are you using a DisplayUGUI component or something? I wonder if perhaps before you CloseVideo () you could set the CurrentMediaPlayer field in DisplayUGUI component to null? It would be an interesting test.

    If you hare using DisplayUGUI component then I've attached a slightly updated script here which has some extra robustness built in for when changing MediaPlayer videos.

    Also if you're interested (and none of the above helps) we can send you a copy of the current v1.3.6 beta to see if that helps.

    Thanks,
     

    Attached Files:

  34. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Messages:
    1,075
    Hi Jeroen,

    Yup Hap inside MOV is supported :) Currently for Windows 7 and below only, but in the next update for all windows versions.

    Cheers,
     
  35. phileday

    phileday

    Joined:
    Feb 8, 2014
    Messages:
    50
    You mention you were hoping to release the update soon. Is there a chance that will be this week? I'm happy to try a beta release if you thinks it's going to be a bit longer.
     
  36. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Messages:
    1,075
    Yes it's coming out this week :) Just wrapping up the last few things.
     
  37. phileday

    phileday

    Joined:
    Feb 8, 2014
    Messages:
    50
    Excellent :) very much looking forward to it.
     
  38. jeroenvdv

    jeroenvdv

    Joined:
    Oct 25, 2010
    Messages:
    36
    You're doing an amazing job with this package! Much appreciated! Waiting for that new version :)
     
  39. keenanwoodall

    keenanwoodall

    Joined:
    May 30, 2014
    Messages:
    442
    I'm really enjoying this! It's very easy to use. I tried putting a youtube url as the url path for a video but nothing was displayed. Is this not supported or is using the youtube link incorrect?
     
  40. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Messages:
    1,075
    Thanks! Yes YouTube urls are not supported yet. Maybe in the next next version... We haven't heard a lot of demay for it so we're focusing on adding lots of other features instead :)
     
  41. B_Theoriz

    B_Theoriz

    Joined:
    Jun 17, 2016
    Messages:
    2
    Hi!

    I just tried the free version of the asset, it's really great !
    I want to use it to make a material applied to a mesh with an animated texture, and with a specific tiling and offset. But I noticed the "Apply to Material" script lock tiling to 1 and offset to 0. I tried to disable this lock and specify another tiling, but the texture doesn't repeat, even if the wrap mode is set to "Repeat".
    So is it possible to make a video texture repeat as any other "classic" texture ? If not, should it be possible to add this feature ?

    EDIT : Ok, my first test was on Unity 5.2.4, and tiling does not work. Then I tried on Unity 5.3.4 and it seems to work perfectly.
     
    Last edited: Jun 17, 2016
  42. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Messages:
    1,075
    Hi, glad to hear it's working! We will look into this issue of tiling not working on older version of Unity.

    Thanks!
     
  43. phileday

    phileday

    Joined:
    Feb 8, 2014
    Messages:
    50
    Hi
    You mentioned you would be releasing the latest version by the end of the week. Will that become immediately available for download or is there a Unity assessment process before it is released on the Unity Store?

    Phil
     
  44. Tom-Goethals

    Tom-Goethals

    Joined:
    Mar 6, 2015
    Messages:
    35
    Hi Andrew,

    I've got 2 GameObjects, each with a MediaPlayer and a DisplayUGUI.

    I've replaced the DisplayUGUI.cs file with the new one. I'm still on GLES2+3 and made double sure all eventListeners are destroyed and Close is called. I'm calling Close on video1 after the firstFrameReady of video2 is called as to avoid a white flash between the videos. I'm also setting CurrentMediaPlayer to null before calling Close now.

    Problem persists (iPad Air 1)
    Could send me the 1.3.6 so i can test?

    I'll on my end try to strip the loading of the videos to make sure it's not something else in my application.
    The weird thing is, if I use Apples tools to do some profiling. (Instruments->Leaks) there is nothing substantial there.
    But i'm not a pro on the apple side of things and don't know if i'm interpreting those numbers/debug tools correctly.

    Great work on the upcoming features!!, HAP compatibility will, for us, remove the need for the older plugins. Awesome!
    Also, thanks for the great support, really appreciated.

    [EDIT: no video loading removes the crashes, so it's most probably something there

    Could it be that firstFrameReady is not always called on iOs therefor not closing the video..?]
     
    Last edited: Jun 17, 2016
  45. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Messages:
    1,075
    Yes it was meant to be before the end of the week but we've had some unexpected iOS issues holding us up. Email unitysupport@renderheads.com with your invoice attached and I'll send you the current beta.

    Thanks,
     
  46. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Messages:
    1,075
    Hi Tom,

    Email unitysupport@renderheads.com with your invoice attached and we'll get the beta right over to you.

    Sadly it won't include our fix to the Metal memory leak as that's what we're just finishing up before the release.

    If you could send us your stripped down scene to test with that would be great!

    Thanks,
     
  47. phileday

    phileday

    Joined:
    Feb 8, 2014
    Messages:
    50
    Thank you very much for your offer. I've emailed my invoice to you and look forward to integrating the beta into my next beta :)
     
  48. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Messages:
    1,075
    done :)
     
  49. fklingler

    fklingler

    Joined:
    May 29, 2015
    Messages:
    10
    Is there an easy way to detect if the PC is running Windows 8 or Windows 10, so I can know if I need to download the H265 or the H264 version of the video?
    Or better, a way to detect if the system supports H265, so it can be multiplatform more easily?

    On another note, is there an update on the ETA for the 1.4 version? I'm really interested in the Metal memory leak fix!

    Thanks,
     
  50. andrydeen

    andrydeen

    Joined:
    Aug 11, 2012
    Messages:
    37
    Hi .
    We are using Samsung S6 + Gear VR for playing 360 videos in 4K resolution. After around 15 minutes the phone is overheating and the application is closing down. 2K video makes the phone to overheat in 30 min .

    Tested this in a scene which only has the video sphere, video player and a camera . Is anyone else experiencing the same issue by any chance?

    Thanks