Skip to content

Commit 8eae09f

Browse files
committed
Add video flip workaround
1 parent dffb898 commit 8eae09f

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Runtime/Scripts/GameRecorder.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ public class GameRecorder : MonoBehaviour
2626
[Tooltip("If enabled, renders the mouse cursor position in the recorded video.")]
2727
public bool RenderCursor = false;
2828

29+
[Tooltip("If enabled, mirrors the video vertically (flips it upside down).")]
30+
public bool MirrorVertically = false;
31+
2932
// set this to a render texture to capture a specific render texture instead of the screen
3033
[HideInInspector]
3134
public RenderTexture CaptureRenderTexture;
@@ -129,7 +132,7 @@ void Start()
129132
}
130133

131134
// Initialize the video encoder with the output resolution
132-
_videoEncoder = new VideoEncoder(_outputWidth, _outputHeight, FrameRate, RecordingDuration, outputDirectory);
135+
_videoEncoder = new VideoEncoder(_outputWidth, _outputHeight, FrameRate, RecordingDuration, outputDirectory, MirrorVertically);
133136

134137
_captureInterval = 1.0f / FrameRate;
135138
_nextCaptureTime = Time.time;

Runtime/Scripts/VideoEncoder.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public class VideoEncoder
4141

4242
// Unique instance identifier to prevent conflicts between multiple instances
4343
private readonly string instanceId;
44+
45+
// Control vertical mirroring of the video
46+
private readonly bool mirrorVertically;
4447

4548
// if set to true, the encoding thread will pause adding new frames
4649
public bool IsPaused { get; set; }
@@ -52,11 +55,12 @@ public class VideoEncoder
5255
private volatile bool _stopRequest = false;
5356
private volatile bool _stopRequestHandled = false;
5457

55-
public VideoEncoder(int width, int height, int frameRate, int recordingDurationSeconds, string baseOutputDir = "Recording")
58+
public VideoEncoder(int width, int height, int frameRate, int recordingDurationSeconds, string baseOutputDir = "Recording", bool mirrorVertically = false)
5659
{
5760
this.width = width;
5861
this.height = height;
5962
this.frameRate = frameRate;
63+
this.mirrorVertically = mirrorVertically;
6064

6165
// Create unique instance identifier and output directory
6266
this.instanceId = Guid.NewGuid().ToString("N").Substring(0, 8); // Use first 8 characters of GUID
@@ -135,6 +139,13 @@ public void StartEncoding()
135139
arguments.Add("-preset");
136140
arguments.Add(presetName);
137141
}
142+
143+
// Add vertical mirroring filter if enabled
144+
if (mirrorVertically)
145+
{
146+
arguments.Add("-vf");
147+
arguments.Add("vflip");
148+
}
138149

139150
arguments.AddRange(new[]
140151
{

0 commit comments

Comments
 (0)