Search Unity

Question Video Player seamless loop possible?

Discussion in 'Audio & Video' started by voidcoder, Jan 6, 2024.

  1. voidcoder

    voidcoder

    Joined:
    May 1, 2017
    Posts:
    4
    Hi. Looked everywhere through the docs, forums and elsewhere and can't find the answer to this simple question: does the native Unity Video Player component support true seamless video looping by design?

    To be clear, I'm not talking about automatically restarting playback at the end of track. As in automatically calling VideoPlayer.Play() at the end of track. This will inevitably cause visually noticeable hiccups as the codec needs to restart video asset streaming, re-parse video container, pre-cache a portion of decoded video before the first frame is available for rendering.

    What I'm talking about is a true seamless loop where Video Player, providing VideoPlayer.Loop is set, after decoding and buffering the last video frame in the track will instantly seek back to frame 0 and start decoding that. So that no artificial visual gaps present when the track restarts.

    Specifically asking about a simplified case with local packaged video assets only and no audio, just video.

    I obviously tried experimenting before asking here and I couldn't see any visual gaps when looping a seamless video track. At least it worked perfectly fine in 2022.3 on my Mac and iPhone devices. However it is not clear whether it works because my test devices are powerful enough to handle video stream restart within a duration of one frame or because the Video Player is indeed implementing true seamless looping. Same kind of test used to produce horrible noticeable video stutters when I tried it few years ago with older Unity version. Fear whether this will hold for other platforms and esp older low end h/w.

    Any ideas please? Can a Unity dev please confirm whether a true seamless video loop is supported by design as it is not clear from documentation :(

    Thanks
     
    bepplergz likes this.
  2. voidcoder

    voidcoder

    Joined:
    May 1, 2017
    Posts:
    4
    Nothing in the docs, no response from devs, no access to the sources (unlike UE, Godot and pretty much every other engine out there) to just go and dig the answer out on your own. What else can you try?

    Not surprising devs leaving Unitytanic in droves ...
     
  3. SeventhString

    SeventhString

    Unity Technologies

    Joined:
    Jan 12, 2023
    Posts:
    416
    We did lose video people recently, notably @The_Island who was the "forum video guy".

    I'll try to bounce your question around, as I am certainly not a "video guy"!
     
  4. SeventhString

    SeventhString

    Unity Technologies

    Joined:
    Jan 12, 2023
    Posts:
    416
    So I got the short and sweet answer: "No :oops:"

    I have to say that our small media team is strongly advocating to increase our resources to improve the video player implementation and integration across other Unity features (among numerous other things...).

    Understandably, "now" is not exactly the best time for this, but I believe we're making a good case for this internally. Comments like yours also help us demonstrate some of these cases.

    But what would reeeaaally help us...

    ...is if you could list relevant or cool (or even standard!) usages for Video Player that are not supported or possible yet. We certainly have a small list of our own, but we're not exactly game designers so we're certainly missing out on some.

    Cheers!
     
  5. voidcoder

    voidcoder

    Joined:
    May 1, 2017
    Posts:
    4
    Thanks Seven! The "no" answer is nonetheless an answer. Much appreciated.

    Shame proper looping not supported though. I added it to "Audio/Video Public Roadmap - Call for Feedback" sticky thread above.

    As for applications - pretty much everywhere you'd use video loops in the game. Honestly not even sure what was the point of having a Video Player loop option w/o properly implementing it. You'd certainly not want the rather noticeable irritating black screen or frozen frame delay when video restarts. Especially noticeable when looping short videos as you see constant hiccups.
     
  6. DominiqueLrx

    DominiqueLrx

    Unity Technologies

    Joined:
    Dec 14, 2016
    Posts:
    260
    Hey voidcoder!

    Seamless looping and a precise callback on loop point proved to be unachievable on most platforms, at least with the high-level third party APIs we're going through at the moment (think Media Foundation, AVFoundation, Android/MediaCodec, etc). We found this out during early implementation when we were too far ahead in the release cadence to revise the implementation choice, so a visible hiccup may happen.

    There won't be a black frame, but if the system doesn't have enough breathing room to restart playback before the previously-buffered content is exhausted, you'll perceive the transition. We've been polishing this over time, but there's no smoothness guarantee.

    It's not just looping that suffers in this way: transition from one clip to another (in a playlist situation, say) is also quite hard to accomplish with the VideoPlayer in its current state. Doable, but lots of ahead-of-time preparation handling to be done under the hood by the user with a second VideoPlayer instance that you double-buffer with.

    So like SeventhString was saying, it's good for us to know whether there are people for who this is important, because this has also irritated me from the very beginning. If we have data to show there's traction for this, then it makes it a valid item to put in the design requirements of a future generation implementation.

    As for the value of looping without smoothness guarantee, the typical scenario where this won't matter is if your videos, for example, fade-in/out from/to black, then it'll go unnoticed. But this admittedly doesn't cover a very large spectrum of what looping can be used for.

    Hope this helps!

    Dominique
    A/V developer at Unity
     
  7. Zai580

    Zai580

    Joined:
    Nov 13, 2023
    Posts:
    1
    Based on the information available and the lack of explicit documentation regarding seamless looping in Unity's native Video Player component, it's advisable to consider a few points:
    1. **Experimentation:** Your experimentation on Mac and iPhone devices with Unity 2022.3 is a good starting point. If you're not noticing visual gaps during looping in your specific use case, it's a positive sign.
    2. **Device Variation:** Keep in mind that performance and behavior might vary across different devices and platforms. Your test devices may be powerful enough to handle seamless looping, but it's essential to consider the potential variability on older or lower-end hardware.
    3. **Documentation Check:** While there may not be explicit documentation stating seamless looping, it's worth checking the official Unity documentation for any updates or discussions on video looping behavior.
    4. **Alternative Solutions:** If seamless looping is critical and Unity's Video Player doesn't provide the desired behavior, consider exploring alternative solutions or assets from the Unity Asset Store that specialize in video playback and looping.
    5. **Unity Updates:** Unity may introduce changes or improvements in subsequent updates. Ensure that you're using the latest version of Unity to take advantage of any enhancements or fixes related to video playback.

    while Unity's Video Player component may not explicitly mention seamless looping in its documentation, your positive results from experimentation are promising. Keep testing on various devices, stay updated with Unity releases, and seek insights from the Unity community for a comprehensive understanding of the behavior across different scenarios.
     
  8. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,943
    Hi @DominiqueLrx
    Im building a unity app for iOs and Android where seamless looping is required. Any plans for tackling it in atleast Unity 6?
    Thanks