Search Unity

Video Video Player Glitchy and Stutters

Discussion in 'Audio & Video' started by Zullar, Apr 23, 2019.

  1. Zullar

    Zullar

    Joined:
    May 21, 2013
    Posts:
    651
    I have a .mp4 video which plays smoothly in VLD and Windows Media Player.

    Fresh windows PC reboot + new blank project and when I play the clip with Video Player it's glitchy.

    Any ideas what to look into? Thanks.
     
    guifs, wavekeyboard and EricWilliams like this.
  2. jocyf

    jocyf

    Joined:
    Jan 30, 2007
    Posts:
    288
    • Encode to: Mp4 with H264.
    • Profile: Baseline 3.0.
    • Encoder present: Medium or Fast or VeryFast.
    • FrameRate = 30fps (not 60fps).
    Use HandBrake (it's free) to convert it at the selected size (HD, FullHD, SD, etc...). Get your mp4 and convert it to mp4 again using these adjustments.
     
    yong888, DhiaSendi, IztokMan and 2 others like this.
  3. JerryWitt

    JerryWitt

    Joined:
    Feb 15, 2019
    Posts:
    3
    What pixel size is your video? What is the frame rate?

     
  4. jocyf

    jocyf

    Joined:
    Jan 30, 2007
    Posts:
    288
    Frame rate: 30 fps (i've tried at 60fps but it not always it works as it should)
    Pixel size... Right now I'm using 1280x720 and 1024x1024 clips
     
    yong888 likes this.
  5. Zullar

    Zullar

    Joined:
    May 21, 2013
    Posts:
    651
    Video was 1920x1080 @ 60FPS.

    I built the .exe and it was smooth. Only glitchy in editor it seems.
     
  6. jocyf

    jocyf

    Joined:
    Jan 30, 2007
    Posts:
    288
    Ah, ok. I see you are compiling for windows... I was talking about mobile.

    On the other side, if you only play one video, you shouldn't have any problem. Playing several videos in sequence is more tricky and it doesn't work smoothly using 60fps clips (talking about Mobile target here).

    In my experience in windows & IOS playing videos works just fine (as it should to), on android preparing de videoplayer take too much time (a big problem if you are playing several videos in sequence) and on Mac OSX it was unusable, it doesn't play fine a single clip.
     
    guifs likes this.
  7. Zullar

    Zullar

    Joined:
    May 21, 2013
    Posts:
    651
    I haven't tested Android but have you tried to call VideoPlayer.Prepare( ) on all your different clips before playing? This may push the loading to the beginning and avoid hickups when playing from and transitioning from one clip to the next. Just an idea to try.
     
  8. jocyf

    jocyf

    Joined:
    Jan 30, 2007
    Posts:
    288
    Yeah, I'm preparing all videos before playing them. The Prepare function is superfast on IOS, but in Android it doesn't work so well. On the other side Preparing a video clip while playing another one, create some hickups in the player in screen because all runs on the same threath.

    The idea under my app is to play a videoclip depending on the user action, so I have to prepare the potential clips before the player can interact... (is a sort of interactive movie) and once the select clip is playing you may have to prepare another potential clips (and release the previous one) in order to let the player choose something again.
    It all work perfectly fine on IOS and windows, but it's unusable on Android for that specific reason: The Prepare funcion can not keep up the users interactions.

    I'm using muted audio clips. The apropiate audioclip (a separate wav file) is played manually using my own manager because there is another problem when start playing already prepared clips with audio: there is a delay for half second on IOS. The video just stops for half second and then start playing normally. Using my own audioplayer sincronized with the videoplayer is not a perfect solution (has sincronization problems when pausing and resuming again, for example) but works fine (it works better than playing the video with the audio channel already in the clip).
     
    guifs likes this.
  9. guifs

    guifs

    Joined:
    Sep 13, 2019
    Posts:
    1
    thank you all. I saw my problem with the video here. Special thanks to jocyf who saved me in this video problem on android
     
    jocyf likes this.
  10. aurkoroy

    aurkoroy

    Joined:
    Apr 7, 2020
    Posts:
    1
    I was having similar issues while playing video in macOS (10.15.4). For me setting codec to H265 at transcode options at the asset import settings did the trick. Video players much better then before. Hope it help!
     
    Zullar and jocyf like this.
  11. dcamod

    dcamod

    Joined:
    Oct 29, 2019
    Posts:
    19
    This is nice information but could you please explain why this works or direct me to some place that might help explain this?
     
  12. jocyf

    jocyf

    Joined:
    Jan 30, 2007
    Posts:
    288
    Download Handbrake (a free video converter) and look at the options in the Video tab.
    There are more options (resolution, crop parameters) but the important ones to make it work in Unity without transcoding are those related to video encoder.

    https://handbrake.fr

    Cheers,
    Jocyf
     
    IztokMan likes this.