Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

Video VideoPlayer.canSetSkipOnDrop purpose

Discussion in 'Audio & Video' started by EddieOffermann, Mar 11, 2018.

  1. EddieOffermann


    Sep 13, 2015
    The docs describe this setting as follows:

    public bool canSetSkipOnDrop;
    Determines whether the VideoPlayer skips frames to catch up with current time. (Read Only)

    Set to true to enable the VideoPlayer to skip frames to catch up with the current play time if it is currently behind for some reason. Set to false to ensure all frames are played without skipping.​

    This is a read-only attribute, so the second paragraph of the description is meaningless.

    If this attribute cannot be set manually, what is determining its value?

    Additionally, I can set VideoPlayer.skipOnDrop as desired - but the description seems to imply that doing so would have no effect if canSetSkipOnDrop is set to false - and testing to see if this attribute has any effect is problematic.

    Anyone have any idea what drives the canSetSkipOnDrop value? Is it "False" for everyone?
  2. pequodification


    Nov 8, 2016
    Did you make any progress on this?

    It appears to me that VideoPlayer.skipOnDrop is always set to true on Android and VideoPlayer.canSetSkipOnDrop is set to false (at least it is in the editor and on my Pixel XL).

    I'm using Unity 2017.4.0f1 on MacOS.
  3. DominiqueLrx


    Unity Technologies

    Dec 14, 2016
    Hi all!

    The doc for canSetSkipOnDrop is wrong, I'm in the process of fixing it right now. Here's the full story:


    The API doc for this is correct, although a bit succinct.

    This controls how Unity behaves when the video decoding is not keeping up with the required speed. In video parlance, this is called "dropping frames". It can either:
    1. skip ahead to catch up with Unity's current time, hence the admittedly mysterious "skip on drop" name we chose for this control. This is preferable in situations where, for example, the movie is timed with other events in your game such as animation or audio.
    2. don't skip, thus showing all frames. This will offer the best visual fluidity, at the cost of possibly desynchronizing with other game content. E.g.: playing a silent movie in a loop as a backdrop, or a cut scene with just ambiance music not synced to video content, or looping a small video as a kind of sprite container).
    If the movie being played is way below the limit of what the system can do, there won't be any difference between it being true or false. This is just to control what happens when things are too tight for playback to proceed normally. Of course, we do everything we can to have the best video decoding performance, but sometimes there's just too much to do and video decoding cannot sustain the wanted rate.


    Here, the doc is wrong: it's just a different formulation for the skipOnDrop documentation and I'll fix it.

    This is indeed a read-only property, but what it tells you is whether skipOnDrop can be set. Some decoding backends don't support controlling this behaviour. Typically, decoding backends that are native to the platform (AVFoundation on OSX/iOS, HTML5 <video> on WebGL or the AV player on PS4) are meant for synchronized playback and only work in "skip on drop" mode. The concept of "not keeping up" is foreign to these APIs and it will just do whatever is needed to keep up. It can get ugly (e.g. only show the movie's keyframes), but these simply don't offer a mode for us to say that showing all frames is more important than maintaining a target frame rate.

    For other native APIs, we are not using the native playback solution and we instead use our own which provides greater control. We do use the native decoder API, but implement the whole playback mechanics. This is true for Android, for Microsoft platforms, for our webm (vp8/vorbis) software implementation as well as our in-editor-only ogv (theora/vorbis) support.

    A subtlety about this value: it is only meaningful when the video has been "prepared".

    The actual playback backend selected depends on the clip being played. For example, on Windows or OSX, playing a
    webm movie uses a different backend than if you play a mp4.

    So only when the clip has been successfully opened and prepared for playback (see
    VideoPlayer.Prepare()and VideoPlayer.isPrepared) will the value of canSetSkipOnDrop be meaningful. Before this, it will always be false, which probably explains what @pequodification mentions above.

    Therefore, when this value is:

    • true: Go ahead, you can adjust skipOnDrop to your desire.
    • false: The value of skipOnDrop is set in stone. In the current state of things, for playback backends that don't support skip on drop, the value of skipOnDrop will be frozen to true.
    Hope this clarifies things... Sorry about the mixup. I'll now go rewrite the doc for canSetSkiponDrop.

    Dominique Leroux
    A/V developer at Unity
    Railon23 likes this.
  4. skildfrix


    Jun 27, 2017
    Can this also be used on buffering a video on a network? We have a project where we made a video player on the scene and it plays the video through LAN. Due to our hardware limitations to the project, buffering often happens on playing the videos through the network.

    We have a seek function on the video player we've been working on, but there's a problem. The seek bar keeps running even with the video is frozen skipping some of the contents being played. I've been researching through Unity's Video Player API documentations and luckily hit this discussion. So I wonder if this is the function we need to fix it. If not, is there any function available that can fix this problem?

  5. EddieOffermann


    Sep 13, 2015
    @skildfrix - there's some useful information missing from your question in order for someone to give good feedback. Starting with what "this" refers to in your opening sentence, "Can this also be used..."

    Certainly skipOnDrop can be used with streaming video, but since canSetSkipOnDrop only has a meaningful value when the video has been Prepared - and since streaming video has not been Prepared in that sense, I'm not sure you'd be able to determine if you can set skipOnDrop or not. It's going to depend on container, codec, etc.

    The problem you're describing, though, tends to be caused by a combination of factors - encoding settings, server configuration and so on. Whether skipOnDrop is set or unset - or even settable - is probably not what's causing the problem you're seeing.

    This statement is probably wrong: "Due to our hardware limitations to the project, buffering often happens on playing the videos through the network." If you're using videos properly encoded for streaming, and streaming them across a LAN, there's likely no *hardware* reason for you to be experiencing buffering problems. It's worth looking at your encoding settings, instead.

    There's way too much to try to get through to sort this out without more information - and the comment section on an old post is probably the wrong spot.

    Here's what to do next:
    • Make a new post so people will see it.
    • Describe everything you're experiencing
    • Describe what your hardware environment actually is:
      • What are you using for a server?
      • What type of network are you using?
        • What speed is the network? 100mbit? 1gig? 10gig?
        • Wired or wireless?
        • Can you provide any additional information about the network topology?
      • What platform are you building for?
    • Describe your video stream(s):
      • What's your target bitrate?
      • What is your actual bitrate (ie., the runtime and resulting filesize of your streamed footage)?
      • What container type are you using?
      • What codec are you using?
    • Share your code. Specifically, share the code you're using to manage the stream.
    It's possible that you just need to manage the stream a little better during the sync - that you should go to the new frame, then pause the video until you get a frameReady event. You might even already be doing that - but that's why it's so valuable to provide a good amount of information up front in your question.
  6. artemio_morales


    Nov 29, 2015
    I've been playing around with the 'skipOnDrop' attribute and it seems like it's impossible to set this to false. I tried setting it to false in the editor in a clean project, but whenever the video begins playing, the 'skipOnDrop' attribute switches to true. Is this a bug? I'm using 2018.3.0f2.