I\'m using FFmpeg version 3.3.4 (installed via brew) through the command line to record my desktop during some automated tests on my macOS Sierra (10.12.6).
I would
First you need to find the name of the AVFoundation device that corresponds to your screen:
ffmpeg -hide_banner -f avfoundation -list_devices true -i ""
[AVFoundation input device @ 0x7fc1cd40ec60] AVFoundation video devices:
[AVFoundation input device @ 0x7fc1cd40ec60] [0] HD Pro Webcam C920
[AVFoundation input device @ 0x7fc1cd40ec60] [1] FaceTime HD Camera (Built-in)
[AVFoundation input device @ 0x7fc1cd40ec60] [2] Capture screen 0
[AVFoundation input device @ 0x7fc1cd40ec60] AVFoundation audio devices:
[AVFoundation input device @ 0x7fc1cd40ec60] [0] HD Pro Webcam C920
[AVFoundation input device @ 0x7fc1cd40ec60] [1] Built-in Microphone
So my screen is device [2]
because I have two cameras attached and they are devices [0]
and [1]
.
Then, as you are on a Mac, you will probably want to use QuickTime to view videos, so you need to ensure you make videos that are compatible - that means using -pix_fmt yuv420p
.
ffmpeg -f avfoundation -i "2:0" -vf "crop=1024:768:400:800" -pix_fmt yuv420p -y -r 10 out.mov
The 1024x768 are the width and height of the video, and the 400:800 are the offset from top-left of screen that I want to record from.