Hi,
How can i record the camera's view and have a video output?
So thanks.
Hi,
How can i record the camera's view and have a video output?
So thanks.
A good Unity friend of mine (Jake) and I co-developed this script, it will create a command in the Window menu called Recorder. This will open a new window with a UI for configuring the framerate, filename of the image sequence, and a button to start recording:

Instructions:
Save code to a file called Recorder.cs and place it within the Editor folder of your project (if this folder doesn't exist, create one). Click Window>Recorder to open the UI. Once you load the UI, click the record button; it will begin recording when you start playing your game and stop recording when you stop playing your game. Load the image sequence into Quicktime 7 with File>Open Image Sequence and save it out as a movie file in the format of your choice. Email me at josh@whitespacecg.com if you need help.
Note: This records the Game view, but I imagine you could edit it easily to record any camera in your scene; alternatively you could tag the camera you want to record as the MainCamera.
using UnityEngine;
using UnityEditor;
public class Recorder : EditorWindow {
string myString = "FileNameHere";
string status = "Idle";
string recordButton = "Record";
int state = 0;
int fps = 24;
int[] fpsOptions = new int[] {12,24,30,60};
string[] disOptions = new string[] {"12","24","30","60"};
float lastFrameTime = 0.0f;
int imageIncrement = 0;
bool recordVideo = false;
// Add menu named "My Window" to the Window menu
[MenuItem ("Window/Recorder")]
static void Init () {
// Get existing open window or if none, make a new one:
Recorder window = (Recorder)EditorWindow.GetWindow (typeof (Recorder));
window.Show ();
}
void OnGUI () {
GUILayout.Label ("Recorder", EditorStyles.boldLabel);
myString = EditorGUILayout.TextField ("File Name:", myString);
fps = EditorGUILayout.IntPopup(fps, disOptions, fpsOptions);
if(state == 0) { // idle
if(GUILayout.Button(recordButton))
{
imageIncrement = 0;
recordVideo = true;
recordButton = "Stop";
state = 1;
}
}
if(state == 1) { // recording
if(GUILayout.Button(recordButton))
{
status = "Idle";
recordButton = "Record";
recordVideo = false;
state = 0;
}
}
GUILayout.Label (status, EditorStyles.boldLabel);
//myString = EditorGUILayout.TextField ("Text Field", myString);
//groupEnabled = EditorGUILayout.BeginToggleGroup ("Optional Settings", groupEnabled);
//myBool = EditorGUILayout.Toggle ("Toggle", myBool);
//myFloat = EditorGUILayout.Slider ("Slider", myFloat, -3, 3);
//EditorGUILayout.EndToggleGroup ();
}
void Update () {
if (recordVideo == true && EditorApplication.isPlaying){
RecordImages();
Repaint();
} else if (recordVideo == true && !EditorApplication.isPlaying) {
status = "Waiting for Editor to Play";
}
}
void RecordImages()
{
if(lastFrameTime < Time.time + (1/fps)) {
status = "Recording In Progress: Image_"+myString+ "_" + imageIncrement;
Application.CaptureScreenshot(myString + "_" + imageIncrement + ".png");
imageIncrement++;
lastFrameTime = Time.time;
}
}
}
you should capture frame sequences with a script like this and then convert it to a video with some other applications.
Sorry to post to an old thread, but I wanted to provide another option for people who don’t want to buy a commercial product like QuickTime 7.
Using the above method to capture each frame, you can import all of the captured images into Windows Live Movie Maker on Windows and make the duration for each image really small (0.04 roughly equals 24 FPS). Then just save your video in whatever format you want.
I couldn’t get this to work on a mac. Perhaps I’m putting the file inside a wrong folder? Or some other reason? I assumed - “place it within the Editor folder of your project” might be as shown in my image. But I’m thinking it should be somewhere inside a program folder? Any feedback would be much appreciated. Thanks. [747-folder+location.png|747]
@nahthu
I ran into the same issue you did and I can tell you what you issue is. Your file path is [project]>Editor however, it should be [project]>Assets>Editor