U3D VideoPlayer plays video and pits

In the game I made recently, I need to play a few seconds of the studio LOGO title. The video I got is in AVI format. I haven’t used video in U3D before. I thought it was very simple. I didn’t expect it to be 2022. U3D Playing videos sucks. . .

The best plug-in is AVPro. Unless you have a lot of videos to play, there is no need to use plug-ins. One is expensive and the other is very large.

First of all, the format conversion software I use is Format Factory. There will be messy problems when importing various formats into U3D. After importing, it cannot be used or recognized. I made it in OGV format at the beginning. The editor can be used, and the PC side is packaged. It can’t be displayed anymore. In the last various experiments, MPG4 can be used on the PC side.

1. The picture quality must not be 4K, or it is very stuck, it must be below 2K, and if it is still stuck, then reduce it.

2. MPEG4 must be selected for video encoding, other options cannot be imported into U3D.

Secondly, the logic of U3D's VideoPlayer component is that the sound and picture are processed separately.

First hang a video on this component, then output the video to RenderTexture, then come to a RawImage component to accept RenderTexture, if there is sound, then connect it to an Audio Listener, my video has no sound, so the audio processing I Didn't do it here.

RenderTexture can be created with the right mouse button.

Video files can be placed in StreamingAssets or Resources, there is no requirement where they must be placed.

This method is the most convenient and fastest, and there are relatively few things to do. It can definitely be used on the PC side, but I haven’t tried it on the mobile phone.

videoPlayer.Play();  //播放
videoPlayer.Stop();  //停止
videoPlayer.Pause(); //暂停
videoPlayer.Prepare(); //准备
videoPlayer.targetTexture.Release(); //清除残留画面
videoPlayer.started //开始回调
videoPlayer.prepareCompleted //准备完成
videoPlayer.loopPointReached //结尾回调
videoPlayer.time = 5; //视频时间跳到多少秒

Prepare and prepare to complete the callback. If the video is relatively large, I guess it should be prepared first, then called back, and then played, so that it will not be stuck. Because my video is only a few seconds, I didn't try it.

Guess you like

Origin blog.csdn.net/u012322710/article/details/128064050