Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Audio gets messed up if I increase "Playback Speed" in Video Player

Discussion in 'Audio & Video' started by MystFTG, Jun 24, 2020.

  1. MystFTG

    MystFTG

    Joined:
    Apr 28, 2013
    Posts:
    26
    Hi,

    I have a scene with a video player that pops up and plays a different video, depending on where the user clicked.
    That works great so far.

    However, I'd like to increase the speed of the video in certain situations and for that I use the "Playback Speed" setting of the video player.
    This does work, the video plays faster, but the audio of the video file gets messed up. It's faster as well, but you can hear stuttering. There are no error messages or warnings in the console.

    "Skip on Drop" also doesn't do anything in this case.
    Audio output mode is "direct". Changing it to "Audio Source" and adding one to the object, doesn't do anything either when the video plays faster.

    I've tried a few different video files, but it didn't change anything:

    Original video:
    Video: MPEG4 Video (H264) 1280x720 25fps 428kbps [V: h264 high L3.1, yuv420p, 1280x720, 428 kb/s]
    Audio: AAC 44100Hz stereo 106kbps [A: SoundHandler (aac lc, 44100 Hz, stereo, 106 kb/s)]

    Transcoded in unity has the same result (Original, Auto, High, High)

    Modified video with handbrake:
    Video: MPEG4 Video (H264) 1280x720 30fps 237kbps [V: h264 main L4.0, yuv420p, 1280x720, 237 kb/s]
    Audio: AAC 44100Hz stereo 154kbps [A: Stereo (aac lc, 44100 Hz, stereo, 154 kb/s)]

    Maybe I'm using the wrong audio codec? Or something else is not set up correctly.

    I'd really like this to work, because I don't want to start splitting the audio from the video and setting up an audio source and mixer and match the pitch of the audio to the playback speed of the video and adjust the mixer's pitch shifter to make the audio sound better again.

    Thanks in advance :)

    Edit: Just to make sure there's no misunderstanding: Only the audio of the video is stuttering, all other audio elements in the scene are fine.
     
    Last edited: Jun 24, 2020
  2. DominiqueLrx

    DominiqueLrx

    Unity Technologies

    Joined:
    Dec 14, 2016
    Posts:
    256
    Hi!

    The movie file specs look all good so this is not the problem.

    You haven't told us what platform you are using: the result will vary based on the underlying platform's capability. The Apple platforms have a good native resampling implementation that sounds relatively nice when speed changes are done. For platforms that don't offer native support for this (Microsoft, Android, ...), we take a simple approach which is to keep chunks of samples unprocessed, but drop some of the chunks to make up for the speed difference. We cross-fade these chunks so there won't be glitching, but the effect is not as smooth as an actual resampling. This does preserve the signal "recognizability" (useful if you're implementing shuttling through the movie file for cueing for example) but won't be appropriate for more critical listening.

    Can you confirm this is what you're hearing? Or is there something more fundamentally broken?

    Dominique Leroux
    A/V developer at Unity
     
  3. MystFTG

    MystFTG

    Joined:
    Apr 28, 2013
    Posts:
    26
    I'm using Windows 10 Version 1909. Sorry for the confusion.


    Here is a sample of the effect:
    Normal speed: https://vocaroo.com/dbb6a9TqGHP
    1.1 speed: https://voca.ro/arMGAvshzZs
    But the same effect happens with 2x speed and all other values I've tested.

    To me it is quite audible and not really smooth. Hope that helps a bit.
     
  4. DominiqueLrx

    DominiqueLrx

    Unity Technologies

    Joined:
    Dec 14, 2016
    Posts:
    256
    Hi again,

    Thanks for the samples. I confirm this is the current state of things on this platform. Like I mentioned, the original sound stays recognizable, stays synced with video and there are no harmful - for your ears, or your listening hardware - glitches in the sound, but that's about it.

    The smoothness I described is only applicable to a few platforms such as the Apple ones, where we are able to leverage Apple's AVFoundation's audio resampling during playback.

    Sorry that this doesn't match your needs; we may address this in the future but this isn't for the short term.

    Dominique
     
  5. MystFTG

    MystFTG

    Joined:
    Apr 28, 2013
    Posts:
    26
    Thank you very much for the clarification. At least I know I'm not doing anything wrong and that the effect is somewhat intended (at least temporarily). I'll try to find another solution.