- Home /
VideoPlayer from URL has extremely low frame rate in iOS
We need to render a video from URL onto a textured plane using a VideoPlayer object. Here's our code:
public class CustomVideoPlayer : MonoBehaviour { public MeshRenderer video_renderer;
private VideoPlayer player_;
private String video_url = "http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_30fps_normal.mp4";
public void Start()
{
player_ = new GameObject().AddComponent<VideoPlayer>();
player_.playOnAwake = false;
player_.url = video_url;
player_.renderMode = VideoRenderMode.MaterialOverride;
player_.targetMaterialRenderer = video_renderer;
player_.targetMaterialProperty = "_MainTex";
player_.skipOnDrop = true;
player_.isLooping = true;
player_.audioOutputMode = VideoAudioOutputMode.None;
player_.sendFrameReadyEvents = true;
player_.Play();
}
}
If we use a local video file it plays perfectly, but using the URL drops the frame rate to about 3 fps. However, that URL plays fine in my browser. Any suggestions on how to get the URL to play smoothly in Unity?
Hi, @adam_omnivor Did you find a solution to this? I'm currently experiencing the same problem. Playing a 720p 30 second video from a URL on a button press. In the Editor it will play the first few seconds fine but then slow down to about 3 fps.
Answer by lifetree · Apr 16, 2021 at 08:31 PM
Hey @adam_omnivor, we have something similar, but what I have noticed is some videos do NOT lose frame rate, while a few do. They are all the same size, same format, etc. I'm still hunting it down, but thought it might help you. I don't think it is a Unity "core" issue, but possibly an encoding issue.