UnityPlugin-AVProVideo icon indicating copy to clipboard operation
UnityPlugin-AVProVideo copied to clipboard

Android - Audio out of sync when using Unity audio output with a looping video

Open joseph-o3h opened this issue 3 years ago • 15 comments

Describe the issue When using a looping video player on Android with the audio output set to Unity, the audio track loops before the video track, causing the two to desynchronize after the first loop. Does not occur with system audio output and with Unity audio on macOS/iOS.

Your Setup (please complete the following information):

  • Unity version: 2021.3.9f1
  • AVPro Video version (number and edition (trial/core/ultra/enterprise)): 2.6.2 ultra (Also reproduced on 2.4.0)
  • Operating system version: Android 12/13
  • Device model: Samsung Galaxy S21 Ultra, Google Pixel 6
  • Video specs (resolution, frame-rate, codec, file size): 1080x1920, 30 FPS, H.264 + AAC audio, 32.6 MB

To Reproduce Build the sample project (sent by email) for Android and run. Observe the audio getting out of sync when the video player reaches the end of the video and loops.

Videos Video is in streaming assets in the sample project.

Please DO NOT LINK / ATTACH YOUR PROJECT FILES HERE

Instead email the link to us [email protected]

joseph-o3h avatar Sep 30 '22 19:09 joseph-o3h

Hi @joseph-o3h,

Thank you for emailing your project file, that was helpful. I looked at the test media that you provided and found that the video length was 11s 84ms while the audio length was 11s 29ms, which may be causing the loop sync issues. We are looking into how Android treats this.

Chris-RH avatar Oct 03 '22 12:10 Chris-RH

I think we have found the issue. A fix will be incoming in the next release of AVPro Video. If you need a fix sooner @joseph-o3h then please email me over your Unity invoice PDF and I will arrange to get you over an f2 build package.

Ste-RH avatar Oct 03 '22 16:10 Ste-RH

The latest version has been released, please let us know if this has not fixed the issue for you.

Chris-RH avatar Oct 14 '22 13:10 Chris-RH

Still seeing this on 2.6.7

joseph-o3h avatar Jan 05 '23 22:01 joseph-o3h

@joseph-o3h,

Was it working for you in version 2.6.5 and has it since regressed or has it not been fixed at all? Is it still the same Android device?

Chris-RH avatar Jan 06 '23 09:01 Chris-RH

We upgraded directly from 2.6.2 to 2.6.7 so don't know if it is a regression. Same device and same video file.

joseph-o3h avatar Jan 06 '23 09:01 joseph-o3h

Ok, more changes have gone in to try and address this issue. I will include these in the next release.

Ste-RH avatar Jan 10 '23 15:01 Ste-RH

The latest version has been released, please let us know if this has not fixed the issue for you.

Chris-RH avatar Jan 11 '23 14:01 Chris-RH

It has been fixed in 2.7.1, but we have also found a similar issue when seeking (that has not been fixed). It can be reproduced by attaching this script to the media player

using System;
using UnityEngine;
using System.Collections;
using RenderHeads.Media.AVProVideo;

public class SeekVideo : MonoBehaviour
{
    [SerializeField]
    private MediaPlayer mediaPlayer;

    public void Start()
    {
        StartCoroutine(DoSeek());

        IEnumerator DoSeek()
        {
            yield return new WaitForSeconds(4f);
            mediaPlayer.Control.Seek(5.91326492927655);
        }
    }
}

The seek time is important here - it only happens with certain seek times.

joseph-o3h avatar Jan 13 '23 23:01 joseph-o3h

Yeah, I see that. Odd that I do not see it when seeking with the scrub bar in our Demo scene. This one is gonna need some deeper diving. I will schedule in some time to look deeper and get back to you on here when I have something to report.

Ste-RH avatar Jan 16 '23 15:01 Ste-RH

@joseph-o3h I have sent you a plugin set to test via the unitysupport ticketing system

Ste-RH avatar Jan 17 '23 10:01 Ste-RH

@joseph-o3h Did that help?

Chris-RH avatar Jan 25 '23 09:01 Chris-RH

It didn't, I can still see it with the test plugin that you sent me.

joseph-o3h avatar Jan 25 '23 23:01 joseph-o3h

I comment already in the IOS issue but here maybe it makes more sense:

  • On Android (Oculus Quest VR headset)
  • While playing a video (normal 2D video with a standar stereo audio track multiplexed on the video)
  • If you remove the headset and put it back again the audio is delayed

JuanObiJuan avatar Apr 05 '23 09:04 JuanObiJuan

A small change coming in the next version might have an impact on this issue.

Ste-RH avatar Nov 07 '23 17:11 Ste-RH