• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Apr 28, 2019 at 12:34 AM by nintorii for the following reason:

Could not find solution to this particular problem, alternative implementation used.

avatar image
0
Question by nintorii · Apr 09, 2019 at 02:35 AM · audiovideoaudiosourceaudioclipvideos

Extract audio clip from VideoPlayer for real-time processing

I have a VideoPlayer component which plays a video from a designated URL with its audio output mode set to AudioSource. I also have a script which reads an audio clip from an Audio Source and logs to the console whenever it detects a 'beat'. This AudioProcessor script works fine when I manually place an audio clip into my AudioSource, but fails when attempting to read the audio from a VideoPlayer.


I have a helper script which creates a clip and places it into the AudioSource.

 using UnityEngine;
 
 [RequireComponent(typeof(AudioSource))]
 public class FindAudioClip : MonoBehaviour
 {
     void Awake()
     {
         AudioSource audioSource = GetComponent<AudioSource>();
         var samplesLength = AudioSettings.outputSampleRate;
 
         audioSource.clip = AudioClip.Create("", samplesLength, 2, AudioSettings.outputSampleRate, true, null);
         audioSource.loop = false;
         audioSource.Play();
     }
 }

However, the audio clip it places into my Audio Source appears to be devoid of any sort of data. My AudioProcessor identifies that a clip is playing but does not register any beats.

For reference, here is my basic video player script which plays a video from a URL.

 IEnumerator playVideoURL()
     {
         videoPlayer = gameObject.GetComponent<VideoPlayer>();
         audioSource = gameObject.GetComponent<AudioSource>();
 
         videoPlayer.playOnAwake = false;
         audioSource.playOnAwake = false;
         audioSource.Pause();
 
         videoPlayer.source = VideoSource.Url;
         Debug.Log(videoURL);
         videoPlayer.url = videoURL;
 
         videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;
         videoPlayer.EnableAudioTrack(0, true);
         videoPlayer.SetTargetAudioSource(0, audioSource);
 
         videoPlayer.controlledAudioTrackCount = 1;
         videoPlayer.Prepare();
 
         while (!videoPlayer.isPrepared)
         {
             yield return null;
         }
 
         image.texture = videoPlayer.texture;
 
         videoPlayer.Play();
         audioSource.Play();
 
         AudioProcessor.audioReady = true;
     }

alt text

inspector.jpg (53.5 kB)
Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image jgmakes · Apr 12, 2020 at 02:03 AM 0
Share

I know it's been a while, but I'm curious if you ever figured this out!

avatar image slake_it · Feb 24, 2021 at 10:45 AM 0
Share

How did you solve it ?

Thanks

avatar image asabituinc · Apr 13 at 03:33 AM 0
Share

Did you ever figure this out?

0 Replies

  • Sort: 

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

138 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to record audio in chunks and send through websocket? 0 Answers

2.1ch, 4.1ch, 6.1ch 音源の再生方法について ( About how to play 2.1ch, 4.1ch, 6.1ch sound source) 0 Answers

Unity crashing on audio but not in editor? 0 Answers

Noise cancelling 0 Answers

footSteps without using audio.isPlaying 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges