Skip to content

Commit

Permalink
Allow activation of video-capture w/o starting the recording at the s…
Browse files Browse the repository at this point in the history
…ame time.
  • Loading branch information
MerlinCooper committed Jun 5, 2020
1 parent b253c1e commit 15f4b14
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
17 changes: 12 additions & 5 deletions Phases/CaptureRace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ internal void _CaptureRaceTest(Action<string> onComplete, IEnumerable<DataSample
//Retrieve list of raceEvents selected depending on the duration of the highlight video
var totalRaceEvents = RaceEventExtension.GetInterestingRaceEvents(overlayData.RaceEvents.ToList());

//set iRacing Replay to Race start and ensure that iRacing is playing out replay at normal speed
ApplyFirstLapCameraDirection(samples, replayControl);

/*//set iRacing Replay to Race start and ensure that iRacing is playing out replay at normal speed
iRacing.Replay.MoveToFrame(raceStartFrameNumber); //move in iRacing replay to start of Race
iRacing.Replay.SetSpeed((int)replaySpeeds.normal); //set replay speed to normal
iRacing.Replay.SetSpeed((int)replaySpeeds.normal); //set replay speed to normal*/

//Record the selected race events into a highlight video
var highligtVideoCapture = new VideoCapture(); //create instance to control by sending hot-keys to recording software (tested with OBS)
Expand All @@ -75,17 +77,22 @@ internal void _CaptureRaceTest(Action<string> onComplete, IEnumerable<DataSample
foreach (var raceEvent in totalRaceEvents)
{
TraceInfo.WriteLine("ADV_RECORDING: Type: {0} | Durations-Span: {1} | ".F(raceEvent.GetType(), raceEvent.ToString()));
//pause recording software before jumping to new position in iRacing Replay
highligtVideoCapture.Pause();

//jump to selected RaceEvent in iRacing Replay
int framePositionInRace = raceStartFrameNumber + (int)Math.Round(raceEvent.StartTime * 60.0);
iRacing.Replay.MoveToFrame(raceStartFrameNumber + (int)Math.Round(raceEvent.StartTime * 60.0));

Thread.Sleep((int)(1000 * raceEvent.Duration)); //pause thread until scene is fully recorded.

//pause recording software before jumping to new position in iRacing Replay
highligtVideoCapture.Pause();




highligtVideoCapture.Resume(); //resume recording

Thread.Sleep((int)(1000*raceEvent.Duration)); //pause thread until scene is fully recorded.

}
} else { //Code to be removed after being able to implment working solution where analysis phase and replay-capture phase are distinct processes.
//use local variables for original code instead of global variables introduced to support full analysis in analysis-phase
Expand Down
4 changes: 2 additions & 2 deletions Phases/Direction/VideoCapture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class VideoCapture
List<CapturedVideoFile> captureFileNames = new List<CapturedVideoFile>();
videoStatus curVideoStatus = videoStatus.stopped;

public void Activate(string workingFolder)
public void Activate(string workingFolder, bool bStartRecording = true)
{
this.workingFolder = workingFolder;
this.started = DateTime.Now;
Expand All @@ -47,7 +47,7 @@ public void Activate(string workingFolder)
timer.AutoReset = false;
timer.Enabled = true;

if (curVideoStatus != videoStatus.running)
if (bStartRecording & (curVideoStatus != videoStatus.running))
{
SendKeyStroke_StartStopp(); //Send hot-key to start recording
curVideoStatus = videoStatus.running;
Expand Down

0 comments on commit 15f4b14

Please sign in to comment.