Recently, one of my colleagues encountered issues with DRM "protected" content where he had to resort to using TeamViewer to record content he had legitimately paid for.
This situation struck me as absurd — not the recording itself, but the fact that someone paid for content yet has been prevented from downloading or recording it for personal use which I have recently (somewhat) covered in my blog The Broken Digital Promise
But I digress. I was convinced there must be a more efficient solution than using two computers connected via TeamViewer. Whatever the solution, I suspected it would likely involve FFmpeg in some capacity. As it turns out, FFmpeg alone was indeed the answer.
The script available on my GitHub contains both the complete command and detailed documentation explaining each parameter.
For my implementation, I've leveraged my dedicated NVIDIA GPU to handle the encoding/decoding workload, significantly reducing CPU usage during recording sessions. If you're using AMD graphics or intend to use CPU-only encoding, I recommend consulting the FFmpeg documentation before running this script to make appropriate adjustments for your hardware.
If you find ways to improve it (and I am sure there are many) please feel free to open a PR or email me.