当我使用VideoPlayer.playbackSpeed更改Unity 5.6中视频的速度时,除了音频,它的工作正常。开始听起来很糟糕。有什么帮助或建议吗?

IEnumerator playVideo()
{
    videoPlayer = gameObject.AddComponent<VideoPlayer>();

    audioSource = gameObject.AddComponent<AudioSource>();

    videoPlayer.playOnAwake = false;
    audioSource.playOnAwake = false;
    audioSource.Pause();

    videoPlayer.source = VideoSource.Url;
    videoPlayer.url = @"C:\UnityRepo\VideoPlayer\Assets\musicsheet_8326cca0-f00c-11e5-86c5-ebc45ba9e8dc.mp4";
    //videoPlayer.url = "http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4";

    videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;

    videoPlayer.EnableAudioTrack(0, true);
    videoPlayer.SetTargetAudioSource(0, audioSource);


    videoPlayer.Prepare();

    beginWaitTime = Time.time;
    while (!videoPlayer.isPrepared)
    {
        yield return new WaitForEndOfFrame();
    }
    endWaitTime = Time.time;

    Debug.Log(endWaitTime - beginWaitTime);
    PrepareTime.text = (endWaitTime - beginWaitTime).ToString();

    image.texture = videoPlayer.texture;

    videoPlayer.Play();
    audioSource.Play();
}`

最佳答案

如果更改视频的速度,则音频的速度也会更改,以匹配视频。如果这对您来说并不重要,并且您希望音频保持其初始速度,则可以尝试在第二个播放器中仅导入音频并使VideoPlayer静音。

您可以检查this topic有关从C#中的mp4文件中提取音频的问题。

关于c# - 如何在具有良好音频的Unity 5.6中更改视频的速度?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43917050/

10-10 03:06