I'm trying to use the screenscapture command to capture video using the '-v' option.
When I run the command from a command prompt it captures video as expected. And the ps aux | grep screencapture shows that it is running. And screencapture renders a frame around the recording area as expected. And pressing Control-C ends the recording and the resulting file gets populated with a video.
When I run the same command in KM, I know the command runs because the .mov file gets created but it only gets an initial image, and not a video. The ps aux | grep screencapture shows that it's no longer running. And no frame is rendered around the recording area.
Any idea what I'm doing wrong?
Note: If you try this you'll need to delete the .mov file between attempts. If the file exists when screencapture ends then the file will not be overwritten.
I'm not absolutely certain I'm correct on this but...
For the video record function screencapture is running as an interactive process. Termination as you say is accomplished with Ctrl-C.
Keyboard Maestro's Execute a Shell Script action is a script-runner mechanism and not an interactive terminal, so it has no means to allow the script to keep running and abruptly terminates.
I think there's no way to use Keyboard Maestro for this directly, although I suspect you can script the Terminal.app with AppleScript to do the job.
Following Chris' advice I wrote the following. I'm posting this here in case someone else finds the same need.
This sample does the following:
Allows KM to create a terminal command that runs screencapture in video mode, complete with embedded variables.
Has AppleScript ask KM for the value of a variable Applescript_CommandString
Opens a terminal window and executes the CommandString in the terminal window
In this case screencapture will wait for a Control-C to terminate
When terminal receives a control-c, then the screencapture command will terminate and the exit command will be issued
Note: By default the terminal window will stay open when it receives the exit command. To change this behavior in Terminal --> Menu --> Preferences --> Profiles tab --> Shell tab; Set When the shell exists to Close the shell if exited cleanly
Note: Screencapture will not overwrite any existing files. You'll need to manage these files separately.