FFmpeg 3.3.4 avfoundation to record only a specific section of the screen on macOS Sierra using the command line

試著忘記壹切 提交于 2019-12-01 01:26:56

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!