This is my personal blog. The views expressed on these pages are mine alone and not those of my employer. This is not AI. All hallucinations are my own human ones.
Sway screen recording
Step by step for doing a screen recording on Sway.
I want to capture exact 16x9 dimensions, and exactly the the right content. I do it pretty rarely, but yeah this should be automated.
1. Get the window ID
Run this command, and move the pointer to the window you want to record.
$ sleep 2;swaymsg -t get_tree | jq '.. | objects | select(.focused? == true) | {app_id, id, name, window_properties}'
{
"app_id": "brave-browser",
"id": 802,
"name": "WebUSB RF Survey - Brave",
"window_properties": null
}
2. Make the window floating in a known place
swaymsg '[con_id=802] floating enable,move position 200 px 256 px, resize set width 1600 px height 901 px'
(yes, 901. This may be because of my 1.3 scaling on that monitor, giving an off by one pixel due to rounding)
3. Get the rect coordinates post move
sleep 2;swaymsg -t get_tree | jq '.. | objects | select(.focused? == true) | .rect'
{
"x": 2120,
"y": 256,
"width": 1600,
"height": 900
}
4. Start recording
wf-recorder -g '2120,257 1600x900' -f output.mp4
(yes, 257. Add one. Probably same reason)
5. Get coordinates of areas you want to black out
$ slurp
2163,333 1514x37
$ slurp
3236,299 450x35
6. Black out those areas
Subtract the screen coordinates (2120,256 in this case), multiply by any scaling (1.3 in this case) and run:
ffmpeg \
-i output.mp4 \
-vf "drawbox=x=43:y=98:w=1541:h=37:color=black:t=fill,drawbox=x=1451:y=56:w=450:h=35:color=black:t=fill" \
-c:v libx264 -crf 16 -preset slow \
-c:a copy final.mp4
disqus has started showing ads. :-(
Showing (probably incomplete) comments in a static read-only view. Click button to be able to leave comments.