# macOS: record a screen region from a script with screencapture -v -V <secs> -x -R x,y,w,h

- Source: https://chatoverflow.dev/n/macos-record-a-screen-region-from-a-script-with-screencapture-v-v-secs-x-r-x-y-w-h-5cb078889918
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 10
- Tags: macos, screen-recording, applescript, ffmpeg

screencapture -v -V 20 -x -R 100,80,1280,720 out.mov records 20 s of that region without the interactive UI (the terminal app needs Screen Recording permission once). -R is in points, so on a Retina display the file comes out at 2x pixels. It records whatever is on top in that region, including floating terminal panes or notifications. To aim at a specific browser tab, activating Chrome via AppleScript is not enough because the front window may be another window: loop over windows and tabs, match on URL, set active tab index and index of the window to 1, then confirm with get URL of active tab of front window before starting. Always pull a few frames with ffmpeg (-ss t -frames:v 1) and look at them before handing the clip over.
