Switching Videoclips for VideoPlayer in Unity degrades FPS drastically - unity3d

I am using the Video player API that unity provides for playing a video on the surface texture. While I am changing the video clip after each update the FPS on the editor is really slow. The switching and loading the new video clip takes a lot of time (500-600 ms)
videoPlayer.clip = videoClips [vindex]; //this command used for changing the videoclip
I just put the timer before and after and found it consumes a huge amount of time.
Can anyone please tell me how to reduce the time and increase the FPS. Any alternative way or suggestion will highly be appreciated. (Platform: Unity Editor on windows)

If the videos are really small, you can consider to use multiple videoPlayer to play each video in the same time. Set the RenderMode to RenderTexture, and switch RenderTexture instead of videoClip.
surface.GetComponent<MeshRenderer>().material = videoPlays[vindex].targetTexture;

Related

unity render a movie as quickly as possible

I am using Unity to create movies. Right now, I create a scene and play it and record it in real time and export the video file. But I'd like render the scene as fast as possible and reduce the time for creating the movie.
How can I render simple scenes faster than real time in Unity? For example, if I have a 10-second movie at 24 frames/second and my machine can render 240 frames in a second, I'd like to finish the job in a second rather than wait for 10 seconds. Working with framerate and time might do the job but I was wondering if there is a better/simpler way to do it.
Unreal Engine's capture movie renders simple scenes faster than real time without me changing anything and I'd like to know if there is something similar in Unity.
Update: You can disable Cap FPS to speed up rendering if you are using the Unity recorder. I am using something else because I want to record the video in a Unity build.

Minimising the shaking or jumpiness of AR video when played over marker image using Vuforia in Unity3D

I am playing video over image target using vuforia plugin in unity3d. It is simple green screen video. I am using shader to remove it.
Sometimes when video played over image target it becomes too shaky and jittery and thus reducing the AR experience. How can I avoid or reduce it.
I tried multiple ways to get rid of it but no success. Here is what I tried:
Previously I was embedding the video in a Plane then I used Quad
but no success.
I tried to change AR camera (World Center Mode) to different
values like FIRST_TARGET,CAMERA and SPECIFIC_TARGET but still same problem.
Also my vuforia target image has 5 rating in vuforia database.
What could be the solution to this problem. Any help would be highly appreciated. Thanks!

Capturing the frames online without slowing the pace of the game

How to capture the background frames while a unity game is running?
I already knew
cam.Render();
Texture2D image = new Texture2D(cam.targetTexture.width, cam.targetTexture.height); image.ReadPixels(new Rect(0, 0, cam.targetTexture.width, cam.targetTexture.height), 0, 0);
and then
converting the texture into an image using EncodeToPng/JPG
But what I have seen using this extra cam.render and encoding to png and capturing the frames differently slow down the operation drastically, takes huge time to do this.
How can I directly get the textures or frames online while a game is running, maybe from the OpenGL calls which GPU are using?
Does anyone have any idea how to achieve this?
Have you tried using Unity's Video Capture API to record gameplay? There are tutorials and instructionals you can find, but the Unity Documentation is a good place to start.
https://docs.unity3d.com/Manual/windowsholographic-videocapture.html
It's flexibly implemented, so you can work around whatever requirements you want in terms of fps, resolution, etc based on your application and how it's set up.

Playing video at different speed on iOS devices?

I would like to play back a video on iPhone/iPad in the background of my game, with opengl rendered 3D on top. The video should speed up and slow down depending of the speed of the player. The video playback speed should be anything between 0 and 2 times regular speed (even faster max speed would be better, if the CPU can handle it).
Is it possible to adjust video playback speed like this? Also, I need to know the currently rendered video frame, so that certain events in the game can be synchronized to the video.

How to "render" a Box2D scene on iPhone

I'm currently using box2d with cocos2d on iPhone. I have quite a complex scene set up, and I want the end user to be able to record it as video as part of the app. I have implemented a recorder using the AVAssetWriter etc. and have managed to get it recording frames grabbed from OpenGL pixel data.
However, this video recording seems to a) slow down the app a bit, but more importantly b) only record a few frames per second at best.
This led me to the idea of rendering a Box2D scene, manually firing ticks and grabbing an image every tick. However, dt could be an issue here.
Just wondering if anyone has already done this, or if anyone has any better ideas?
A good solution I guess would be to use a screen recorder solution like ScreenFlow or similar...
I think your box2d is a good idea... however, you would want to used a fixed-time step. if you use dt the steps in the physics simulation will be to big, and box2d will be unstable and jittery.
http://gafferongames.com/game-physics/fix-your-timestep/
The frame rate will take a hit, but you'll get every frame. I don't think you'll be able to record every frame and still maintain a steady frame rate - that seems to be asking a lot of the hardware.