Tanoda
Recorder.cs
Go to the documentation of this file.
1using System.Collections;
2using System.Collections.Generic;
3using System.IO;
7using NaughtyAttributes;
8using UnityEngine;
9
10public class Recorder : MonoBehaviour
11{
12 private IMediaRecorder recorder;
13 private CameraInput cameraInput;
14
15 void Start()
16 {
17 }
18
19 [Button]
20 public void StartRecording()
21 {
22 recorder = new MP4Recorder(1152, 648, 23, bitrate: 1152*648, filename: Path.Combine(Application.persistentDataPath, Path.GetRandomFileName()));
23 cameraInput = new CameraInput(recorder, new FixedIntervalClock(24), GameObject.FindGameObjectWithTag("VRCamera").GetComponent<Camera>());
24 }
25
26 public async void StopRecording()
27 {
28 var path = await recorder.FinishWriting();
29 cameraInput.Dispose();
30 recorder = null;
31 File.Move(path, path.Replace(".mp4", ""));
32 Debug.Log(path);
33 }
34#if UNITY_EDITOR
35 [Button("Stop Recording")]
36 private void Teszt()
37 {
39 }
40#endif
41
42}
UnityEngine.UI.Button Button
Definition: Pointer.cs:7
UnityEngine.Debug Debug
Definition: TanodaServer.cs:19
Clock that produces timestamps spaced at a fixed interval. This clock is useful for enforcing a fixed...
Recorder input for recording video frames from one or more game cameras.
Definition: CameraInput.cs:19
void Dispose()
Stop recorder input and release resources.
Definition: CameraInput.cs:59
async void StopRecording()
Definition: Recorder.cs:26
void StartRecording()
Definition: Recorder.cs:20
A recorder capable of recording video frames, and optionally audio frames, to a media output....
Task< string > FinishWriting()
Finish writing and return the path to the recorded media file.