Unity AVI Export by RelativeDistance - 1

Importers & ExportersExtensions

Export an MJPG encoded AVI video at runtime or from the editor.

Unity 2019.3.2f1OtherUpdated 1 year agoCreated on March 5th, 2020
Go to source

Unity AVI Export

View WebGL Demo Scene

Export an MJPG encoded AVI at runtime or from the editor. This plugin is a Unity wrapper around this code: MotionJPEGWriter. The AVIs produced by this plugin will play natively on MacOS and Windows without any additional codecs. Plugin should work with all Unity platforms (only Standalone and WebGL tested).

Installation

Import the UnityAVIExport.unitypackage. Then follow either the runtime or editor instructions below.

Runtime Usage

Create a new instance:

AVIExport avi = new AVIExport();

Then use the following methods:

Initialize AVI

avi.Init(camera,width,height,aviFps,gameFps,quality);
  • Camera - Camera reference for AVI output, if null main camera will be used
  • Width/Height - Dimensions of the AVI in pixels
  • AVIFps - Framerate of AVI, decimals ok such as 29.97 NTSC
  • GameFPS - The frame rate the project is currently running at on target platform.
  • Quality - Integer between 0 (worst) - 100 (best) for jpg quality of each frame.

Frame Update

avi.DoUpdate();

Call this every frame in Update, LateUpdate, etc.

Start Recording

avi.startRecording();

Stop Recording

avi.stopRecording();

Get Byte Array

avi.getByteArray();

Save the byte array to a file with something like this:

File.WriteAllBytes("Video.avi" , avi.getByteArray());

See the included demo scene for an example.

Editor Usage

Go to Window->AVI Export to open the editor window.

  • Camera - Camera content for the AVI output, defaults to main camera
  • Width/Height - Dimensions of the AVI in pixels
  • AVI Fps - Framerate of AVI, decimals ok such as 29.97 NTSC
  • Quality - Integer between 0 (worst) - 100 (best) for jpg quality of each frame.
  • Enter Play Mode - Enters play mode when recording begins, stopping recording does not exit plyamode

TODO

  • Currently video only, add audio
  • Improve performance with AsyncGPUReadback (something like 10-20% increase expected)
  • Look into WebGL 2 Render Texture bug and see if there‚Äôs a workaround
Show all projects by RelativeDistance