Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Example Project - Video Player

Discussion in '5.6 Beta' started by LeonhardP, Jan 16, 2017.

  1. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    Hi everybody,
    The project you can download through the link below is meant to grant you immediate access to the new Video Player.

    This affords you the possibility to see this feature in action, without having to implement things yourself. This is supposed to be an elevated starting point for your exploratory adventures in Unity’s Beta.

    Project link (17 MB):
    (Link removed)

    In the 'Cinema' Scene you take place inside a virtual cinema to watch videos of your choice.



    After opening the project in Unity and loading the 'Cinema' Scene, you have to import a video file and assign it to the VideoPlayer component attached to the 'Screen' GameObject.



    Then simply play the scene and press the space bar to start the replay. If you want to enjoy a seamless cinema experience, I recommend building the project once you've set up the video.

    If you don't have any cinematic video material you want to examine, you can download the first part of the Adam demo here (34 MB):
    (Link removed)

    You can find more information about the Video Player here:
    https://docs.google.com/document/d/128X3Wr3xWDK-XTEhwnGkK4-ndqZAezijsZgQY43q0vM/edit

    And here:
    https://forum.unity3d.com/threads/correct-video-format-for-video-playback.446011/

    Please take note that this project will be taken down once the Beta concludes.

    You can use this thread to discuss the subject matter. Feedback is very welcome!

    Edit: Links removed due to end of beta.
     
    Last edited: Apr 3, 2017
    samnarain likes this.
  2. Deleted User

    Deleted User

    Guest

    Sounds great! :)

    Can we use this video player with 5.5.0f3?
     
  3. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    Hi Anne,
    The Video Player is a new feature in 5.6, so unfortunately not.
     
  4. Deleted User

    Deleted User

    Guest

    (sigh) :)
     
  5. Yode_group

    Yode_group

    Joined:
    Apr 5, 2016
    Posts:
    14
    It doesn't work with android? (( I do some optimization for mobile (remove all seats and lights), and set "auto play" for video, but video don't play on Android device. Test it on Sony Z3. In Editor it works flawless.
     
  6. Ziboo

    Ziboo

    Joined:
    Aug 30, 2011
    Posts:
    356
    Hello,

    I tried it with the Adam Video.

    Sound is not working ...
    I checked everything, I'm not mutted, volume is set to 1.

    Changing the playback speed stop the video too at some point...

    Cheers

    EDIT: Audio works with an AudioSource but not with "Direct" Mode
     
  7. CorstiaanMediamonks

    CorstiaanMediamonks

    Joined:
    Sep 14, 2015
    Posts:
    21
    Has anyone succeeded in playing 4K 360 video? I've tried quite a couple of encodings but Unity keeps throwing errors "Error while reading movie" and "Movie encoding error". I've tried H.264 (Main 5.1) and H.265. Any special settings I'm missing?
     
    Joel_Dittrich likes this.
  8. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    You'll have to disable the VideoControl script as well and change the screen Material from ScreenStart to Video. Then It should work with auto play.

    Unfortunately "Direct" mode doesn't work on Windows. I'll look into implementing the AudioSource solution into the project.

    EDIT: Updated the project to play audio via AudioSource.
     
    Last edited: Jan 17, 2017
  9. MarkHenryC

    MarkHenryC

    Joined:
    Nov 30, 2009
    Posts:
    67
    @paskhalov Has now been acknowledged by Unity as reproducible bug 866587 (not working on Android)
     
  10. Yode_group

    Yode_group

    Joined:
    Apr 5, 2016
    Posts:
    14
    It doesn't help :(

    Thx for link. Vote for it.
     
  11. diogocortiz

    diogocortiz

    Joined:
    Aug 18, 2015
    Posts:
    7
    Is it possible to use Video Player in WebGL? I have exported a project using WebGL but the video does not show up. It works fine in Editor.
     
  12. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    870
    Anybody have answer to the question if the video player works in WebGL?

    Im using WebGL and need a video player, I hope you guys havnt forgotten about WebGL, we are people too!

    Can it stream a mp4 video and play it, for example can i tell it to play a video located at www.mysite.com/hello.mp4
     
  13. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    Yes, WebGL is supported. But it works only with URLs and not VideoClips.
     
  14. diogocortiz

    diogocortiz

    Joined:
    Aug 18, 2015
    Posts:
    7

    Attached Files:

    SpencerS likes this.
  15. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    870
    maybe check your CORS, some websites maybe dont want you playing their videos from another site, i think, just trying to help.
     
  16. diogocortiz

    diogocortiz

    Joined:
    Aug 18, 2015
    Posts:
    7
    Hi, yeah. CORS seems to be a problem. I also had problem with Microsoft IIS. I have changed my URL and put it on Apache Server. The video is working fine in WebGL now.
     
    SpencerS likes this.
  17. DCrosby

    DCrosby

    Joined:
    Jan 13, 2013
    Posts:
    86
    I found kind of an obscure Error, using Perforce and was able to resolve it, eventually. Process to re-produce error:

    Have a project working with video in a folder, and video on an object, Branch the Project, open the source, allow to re-compile, and then play / execute, it will come up with a "Can't find movie []" error. I did some looking into where that error lived, so I could see what it was trying to do, it must sin in the source, as it's not in my code, or code I can see. So I tried everything, assigning nothing to the Video Clip, changing the render to texture, renaming things nothing worked, until I remove the movie from the project and brought it back in, re-creating the meta file I assume, and then when I dragged it in it started working, nothing materially changed, other than me removing and having to re-import the movie.
     
  18. stopiccot

    stopiccot

    Joined:
    May 2, 2013
    Posts:
    26
    Running sample project with adam sample video on my Google Nexus 5X (Android 7.1.1). App crahes with stacktrace:
    https://gist.github.com/stopiccot/403b140574a9df8376bd85836f7eada3

    The only thing I modified is VideoControl::Update() method so it starts video automatically:

    Code (csharp):
    1. if (!videoPlayer.isPlaying) {
    2.      videoPlayer.Play();
    3. }
     
  19. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    870
    WebGLMovieTexture doesnt work on Chrome browser, gives error fastSeek is not a function, but it works in firefox.
     
  20. spelletier_bhvr

    spelletier_bhvr

    Joined:
    Feb 9, 2017
    Posts:
    1
    I had the same error as you (AndroidVideoMedia::StartAudioDecoders: Cannot get media track 1 language). To make the example above work on Android, I had to uncheck the "import audio" checkbox in the import settings for the video. I was able to play three videos simultaneously on three different screens.

    Note that this does not work on iOS. Although there is no crash or error messages, no video plays. I tried on iOS 10.2.1 and 8.1.1. Has anybody been able to play videos on iOS using the new VideoPlayer ?
     
  21. caiovosilva

    caiovosilva

    Joined:
    Apr 26, 2016
    Posts:
    1

    Can you please explain how did you get the videos playing on android?

    Here is just a white screen on android
     
  22. Analytics206

    Analytics206

    Joined:
    Feb 26, 2017
    Posts:
    2
    First thank you for setting this project up.
    I am having issues with sound playing back choppy, this is with the Adam video download and with several others I have tried. I am using 5.6.0b9
    thank you for any feed back.
     
  23. Analytics206

    Analytics206

    Joined:
    Feb 26, 2017
    Posts:
    2
    Alright I fixed choppy sound by disabling Adaptive Lighting script. This must be very intense light processing, though my laptop is not top notch it's no slouch but I guess it can't handle adaptive lighting. The frame rate drops from 90 fps to 20 fps with AL script enabled. Which in my opinion is probably the best part of this project. I will try to cut back the lighting and go from there.
    Any advise on keeping the lighting or ways to optimize would be appreciated.
    thank you for your time.
     
    Last edited: Feb 27, 2017
  24. StevenDelrue

    StevenDelrue

    Joined:
    Aug 21, 2014
    Posts:
    16
    It doesn't seem to work on Android when setting an url in code and calling Prepare() (tested on a Samsung S7)

    The app just hangs..
     
  25. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    870
    Its a bug, i saw the same thing, it only plays the URL specified in the Inspector, trying it from code dont work. I wonder who coded this player, i guess he never tried it even once or else he would see that it dont work.
     
  26. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    Glad you like it! The way the adaptive lighting is handled in the project is really demanding in terms of cpu usage (reads out all the pixel colours of every frame to get the average colour of the current frame, and applies that to the directional lights in the scene). There are numerous ways to tackle the generation of this effect differently, but all of them that I can think of come at different costs. You could change the global illumination settings to use the emissive property of the screen material to have an adaptive lighting effect, but this won't cast shadows. Or you could reduce the size of the render texture, the video player is rendering to (so the script wouldn't need to go through that many pixels).

    Some info on the emission parameter of the standard shader:

    https://docs.unity3d.com/Manual/StandardShaderMaterialParameterEmission.html

    The emission approach wouldn't require a script. Unfortunately I am no expert and don't know how to achieve the same effect at lower costs (otherwise I would have done it differently ;) ), and if someone has a better idea how to do it, I would be interested in that as well!
     
  27. YarrySP

    YarrySP

    Joined:
    Sep 20, 2012
    Posts:
    10
    Have you worked with seeking yet?

    Everything works great for me, using the Video Player, except for seeking.

    When I do seeking in the video, using a slider, the video and audio is prone to go out of sync. Even if I use the seekingComplete callback event.
     
  28. MooviEstudios

    MooviEstudios

    Joined:
    Mar 8, 2017
    Posts:
    1
    Can someone please tell me how to get this working on android?
     
  29. lumacode

    lumacode

    Joined:
    Mar 25, 2014
    Posts:
    8
    Video Player still broken on Android (S6, Mali-T760) for me in beta 11...

    The audio plays but video doesn't because the shader fails to compile.

    Extension 'GL_OES_EGL_image_external_essl3' not supported
    Note: Creation of internal variant of shader 'Hidden/VideoDecodeAndroid' failed.
     
  30. dorinc

    dorinc

    Joined:
    Oct 29, 2015
    Posts:
    4
    Any luck with seeking? It is not working for me either.
     
  31. nwxnw

    nwxnw

    Joined:
    Feb 20, 2017
    Posts:
    1
    Thanks for posting this example. This worked fine for me in 5.6b11.

    Are there any examples of viewing a 360 video in Vive? I was able to display a front only view of a 360 video by attaching the VideoPlayer to the Eye of a SteamVR camera rig. However it was very disorienting, double right-left images and the image did not pan when moving the headset. Has anyone succeeded with this and have some tips on how to get it done?
     
  32. luzanb

    luzanb

    Joined:
    Feb 25, 2017
    Posts:
    18
    Last edited: Mar 20, 2017
  33. YarrySP

    YarrySP

    Joined:
    Sep 20, 2012
    Posts:
    10
  34. Mark-Sweeney

    Mark-Sweeney

    Joined:
    Feb 21, 2010
    Posts:
    172
    How can I extract/separate/split the audio from an imported video into an AudioClip so I can get samples from the AudioClip to create a waveform?

    Right now it looks like I have to import audio separately to do that so I can get an array from AudioClip.samples, which means the user has to split video audio and video files before adding them to my app.
     
  35. saik007

    saik007

    Joined:
    May 17, 2016
    Posts:
    9
    Guys...... I'm using unity5.6.0b9 , and all i want to know is does new video player option in unity5.6 supports Android or Not..Because i tried it different times but at the same in the unity documentation i saw that at present it only supports for Standalone and webgl...........and also unity recognized it as a bug : https://issuetracker.unity3d.com/issues/android-videoplayer-not-playing-video

    All i want to know is for now, does unity 5.6.0b9 support video playback for android???


    Regards
    sai.
     
  36. luzanb

    luzanb

    Joined:
    Feb 25, 2017
    Posts:
    18
    I have been using VideoPlayer API as shared in this blog How to use Unity VideoPlayer on RawImage Component on Android Devices with 7.0 and 7.1.1 on Axon 7, Honor 8 and OnePlus 3. On Unity's draft document they mentioned that they are still working on Android. So you may want to use latest Unity 5.6.0f1,
     
  37. saik007

    saik007

    Joined:
    May 17, 2016
    Posts:
    9

    Thank you..........
    But unfortunately it didn't worked for me even in editor..........i tried everything correctly ....Currently i'm using unity5.60b9
    may be that's the issue............I'm gonna upgrade to 5.6.0f2 which released yesterday and gonna try it again.........But it was mentioned there that, there's some issues and crashes when build for android devices lower than marshmallow.............
     
  38. saik007

    saik007

    Joined:
    May 17, 2016
    Posts:
    9
    Guys i have a doubt, I just downloaded unity 5.60f1 candidate-2 let's say after a week unity officially released 5.6 then what should i do:
    1.I should again download everything i.e. again downloading the editor, Tools, Platform supports e.t.c
    or

    2.Only the things which were upgraded, so that no need to waste a lot of time and data. :) I have a slow internet connection

    I'm asking this because, I already have 5.4.3, 5.5.1, 5.60b9, 5.60f1 candidate 2,unity for hololens and i think an another one.......... And i think lot of other developers also want to know about this.........

    And also i want to know what are patches? And How can we attach or upgrade using patches...?
    Or whether Patches is the answer, what i was looking for all this time...............? Waiting for quick response


    Thank you....
     
  39. saik007

    saik007

    Joined:
    May 17, 2016
    Posts:
    9

    If you need it ASAP and ready to spend some bucks.... Then there's EasymovieTexture plugin for android, ios, windows with editor playback for testing...No need to add audiosources and all just put your videos in Streaming folder and that's it but the size of the video will directly affect the build size...So make sure about it.........
     
  40. saik007

    saik007

    Joined:
    May 17, 2016
    Posts:
    9

    Hey i recently upgraded to unity5.6.0f2 and it's going well and the video & audio plays now............But video not playing in android in both url & Asset texture mode, only audio is playing...........I've tested it on lollipop ,marshmallow and even on Nogut but it doesn't work............The phone are coolpad(lollipop), Lenovo(Marshmallow) & nexus(Nogut)
     
  41. luzanb

    luzanb

    Joined:
    Feb 25, 2017
    Posts:
    18
    @saik007 you can issue a bug for this. Go under Help > Report a bug on Unity Menu.