如何用良好的音频改变Unity 5.6中的视频速度?

时间:2017-05-11 13:36:07

标签: c# audio unity3d unity5 video-player

当我使用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();
}`

1 个答案:

答案 0 :(得分:0)

如果更改视频的速度,音频的速度也会发生变化,以便与视频匹配。如果在您的情况下无关紧要并且您希望音频保持其初始速度,您可以尝试仅在第二个播放器中导入音频并使VideoPlayer静音。

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