Recording by mouse movements

Skuatmraa

New Member
I would like to see something similar to what procreate does, which records only when the mouse moves. I want to record a video and if I pause to think about painting I don't want it to record the pause. It will then resume recording when you do something with the hooked program that your using. This way you don't have empty video where I don't do anything.
 

Suslik V

Active Member
@ThunderKathryn after the Pause Recording was implemented in OBS there became possible to trigger the pause/unpause events as hotkeys, let's say, on each mouse move! Thus it is possible to emulate the requested behavior. There is example of the AutoHotkey program script (Windows) that can do the job:
Code:
; Start conditions
; Minimum position change to trigger the recording event, in pixels

DetectionDelta := 5

; Period for movements detection, in ms (main loop)

MainLoopTime := 50

; Time without any movements to trigger the pause event, in milliseconds
; Always set it bigger than main loop time (>50 ms)

TimeoutBeforePause := 1500
CurrentTimeout := 0

; Asume that recording started

recActive := true

; Get mouse initial position

MouseGetPos, x1, y1

; Set timer for 50 ms (main loop)

SetTimer, Label_1, %MainLoopTime%

; No more auto-executed strings (after first "return" word).

return

;;;;;;;;;;;;;;;;;;;;;;;; General assignments ;;;;;;;;;;;;;;;;;;;;;;;;

; Suspend script by ScrollLock press,
; (for easy script termination when important keys in use).
; Pause timers and loops too.
ScrollLock::
{
Suspend
Pause
}
return

; Reflect user actions if any
; Pause recording (Ctrl + F1)
^F1::
recActive := false
return

; Reflect user actions if any
; Resume recording (Ctrl + F2)
^F2::
recActive := true
return

;;;;;;;;;;;;;;;;;;;;;;;; Main loop (mouse moves detection) ;;;;;;;;;;;;;;;;;;;;;;;;

Label_1:
MouseGetPos, x2, y2
; When left mouse down or
; distance exceeds threshold - resume recording and reset current timeout,
; otherwise continue to count timeout
if (GetKeyState("LButton", "P") or (Sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)) > DetectionDelta)) {
 Gosub, Label_4 ; resume recording
 CurrentTimeout = 0
 x1 := x2
 y1 := y2
} else {
 CurrentTimeout += MainLoopTime
 if (CurrentTimeout > TimeoutBeforePause) {
  Gosub, Label_3 ; pause recording
  CurrentTimeout = 0
 }
}

return

;;;;;;;;;;;;;;;;;;;;;;;; Pause recording ;;;;;;;;;;;;;;;;;;;;;;;;

Label_3:
if (recActive) {
 Send, {Ctrl Down}
 Send, {F1 Down} ;
 Sleep, 30 ; pause 30 ms to allow application to recognize the pressed state
 Send, {F1 Up}
 Send, {Ctrl Up}
 recActive := false
}
return

;;;;;;;;;;;;;;;;;;;;;;;; Resume recording ;;;;;;;;;;;;;;;;;;;;;;;

Label_4:
if (not recActive) {
 Send, {Ctrl Down}
 Send, {F2 Down} ;
 Sleep, 30 ; pause 30 ms to allow application to recognize the pressed state
 Send, {F2 Up}
 Send, {Ctrl Up}

 recActive := true
}
return
In OBS set Ctrl+F1 to pause, Ctrl+F2 to unpause the recording;
the AutoHotkey is suspends by ScrollLock key or via the tray menu of the Windows.
Script was not well tested (for me - it works).
 

Warmuptill

Active Member
This sounded interesting so I added the ability to use "mouse cursor is moving" as a possible condition on the macro tab of advanced scene switcher plugin.
With this I am able to set up the following two macros:
Pause.PNG

Resume.PNG

This seems to result in the wanted behaviour of only continuing recording if the mouse is moving.

If you want to give this a try yourself a build of the plugin with this feature should be available here in a few minutes:
(Note that you have to be logged into GitHub to be able to download it)
 
Top