I have an old recording script I made a long time ago, and I wanted to try it with the new Unity Timeline and stuff. I tried it, but the Editor freezes when I press Play. Is there anything I’m doing wrong?
using System;
using System.IO;
using System.Runtime.InteropServices;
using UnityEngine;
public class Recorder : MonoBehaviour
{
private bool _done;
private int _frames = 1;
public int Fps = 24;
public int Frames = 100;
public string Name = “Recording”;
public bool Enabled = false;
// Use this for initialization
public void Start()
{
Time.captureFramerate = Fps;
Directory.CreateDirectory(“Output/” + Name + “/”);
Directory.CreateDirectory(“Output/” + Name + “/Video”);
}
public void Update()
{
if (_done || !Enabled) return;
var output = “Output/” + Name + “/Frame” + _frames + “.png”;
ScreenCapture.CaptureScreenshot(output);
_frames++;
if (_frames <= Frames) return;
Debug.Log(“Done recording.”);
_done = true;
var oldDirectory = Directory.GetCurrentDirectory();
Directory.SetCurrentDirectory(“Output/” + Name);
Debug.Log(system(“ffmpeg -f Image2 -i Frame%d.png -vb 20M -start_number 1 Video/Output.avi”));
Directory.SetCurrentDirectory(oldDirectory);
}
[DllImport(“msvcrt.dll”, CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
private static extern int system(string command);
}
EDIT: Oh and no images actually save
