我刚刚在Mac HighSierra上使用自制软件安装了ffmpeg。 我想记录在我的机器上运行的应用程序的内容(只有视频就可以了((而不是我的整个桌面(。 所以我尝试运行以下内容
davea$ ffmpeg -f gdigrab -framerate 25 -i title=DOSBox
ffmpeg version 3.4.1 Copyright (c) 2000-2017 the FFmpeg developers
built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.4.1 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
Unknown input format: 'gdigrab'
但正如你所看到的,我得到了这个
Unknown input format: 'gdigrab'
错误。 使用ffmpeg在计算机上仅为特定应用程序录制视频的正确方法是什么?
编辑:使用评论中的建议,我得到了另一个错误...
davea$ ffmpeg -f avfoundation -list_devices true -i ""
ffmpeg version 3.4.1 Copyright (c) 2000-2017 the FFmpeg developers
built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.4.1 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
[AVFoundation input device @ 0x7fcbc160d0c0] AVFoundation video devices:
[AVFoundation input device @ 0x7fcbc160d0c0] [0] FaceTime HD Camera
[AVFoundation input device @ 0x7fcbc160d0c0] [1] Capture screen 0
[AVFoundation input device @ 0x7fcbc160d0c0] AVFoundation audio devices:
[AVFoundation input device @ 0x7fcbc160d0c0] [0] Built-in Microphone
: Input/output error
虽然你已经提到了ffmpeg
,我只是想让你知道你也可以实现你所说的"抓住屏幕的一部分">的目标,而无需安装任何其他软件只是使用macOS附带的工具 - 即QuickTime,苹果不幸地称之为"QuickTime播放器">,掩盖了它可以记录和播放的事实。
因此,要开始使用,请按 ⌘space 并开始键入"QuickTime"来对 QuickTime 进行"聚光灯搜索"。一旦它猜到你的意思是"QuickTime",点击输入/返回。
不转到">文件">菜单,然后单击"新屏幕录制"。按下红色的"录制"按钮",它将让您拖出要录制的矩形区域。完成后,"停止"按钮位于屏幕右上角靠近时钟的位置。
avfoundation 输入设备似乎只能捕获整个桌面,但您可以使用裁剪过滤器仅抓取桌面的特定区域。
-list_devices
命令的输出显示两个视频设备:网络摄像头和桌面(名为 [1] Capture screen 0
(。
以下示例将捕获桌面并忽略音频设备。然后裁剪过滤器将从左侧 24 像素和顶部 180 像素的区域制作 800x600 大小的视频:
ffmpeg -f avfoundation -i "1:none" -vf "crop=800:600:24:180,format=yuv420p" output.mp4
添加了格式过滤器以实现 QuickTime 兼容性。