RenderHeads / UnityPlugin-AVProVideo

AVPro Video is a multi-platform Unity plugin for advanced video playback
https://www.renderheads.com/products/avpro-video/
224 stars 27 forks source link

GetSpectrumData does not work with streamed audio #1823

Closed karl- closed 2 months ago

karl- commented 2 months ago

It appears that setting the output mode to "Unity" does not work properly with URL audio sources that are streamed rather than local paths. Setting a breakpoint in AudioOutputManager at the RequestAudio function and stepping through reveals that int channels = mediaPlayer.Control.GetAudioChannelCount(); is always returning < 0 when MediaPath.Path is a URL.

Your Setup (please complete the following information):

To Reproduce

  1. Create a GameObject and attach this script.
  2. Set the Audio Mode for the active platform to "Unity."
  3. Click play.
using RenderHeads.Media.AVProVideo;
using UnityEngine;

public class StreamFFT : MonoBehaviour
{
    // This does not work
    [SerializeField] private string m_Url = "https://streamssl.chilltrax.com:80/";
    // This one works (swap for your own local audio file path)
    [SerializeField] private string m_Local = "/Users/karlh/Desktop/New Unity Project/Assets/CriticalTheme.wav";

    private MediaPlayer m_MediaPlayer;

    void Start()
    {
        m_MediaPlayer = GetComponent<MediaPlayer>();
        m_MediaPlayer.OpenMedia(new MediaPath(m_Url, MediaPathType.AbsolutePathOrURL), autoPlay: true);
    }

    // GetSpectrumData read from AudioSource, etc etc
}
Chris-RH commented 2 months ago

We don't support Shoutcast, so that could be why its not working.
Have you got any other streaming URLs that you can use? either link here on email unitysupport@renderheads.com Which version of AVPro Video are you using? Are you using positional audio at all?

With regards to macOS, this could be the issue: We use MTAudioProcessingTap to extract the audio and route it through to Unity. This in turn requires using AVAudioMix and attaching it to the current player item. Sadly this is where the process breaks down as AVAudioMix does not support HLS media. The documentation for AVAudioMix states the following (available here):

An audio mix can only be used with file-based media and is not supported for use with media served using HTTP Live Streaming.

karl- commented 2 months ago

Thanks for the quick reply. Ok, noted for Shoutcast. I'll test another streaming source. We are not using any positional audio.

We're using AVPro Video 2 from the Unity Asset Store, I'm not sure beyond that. I couldn't find versioning information in the Unity project or menu items for AVPro.

Given that this works with local audio and the lack of Shoutcast support is expected, I think this can be closed. Thanks for your help.