【问题标题】:How do I record a specific application running on my Mac using ffmpeg?如何使用 ffmpeg 录制在我的 Mac 上运行的特定应用程序?
【发布时间】:2018-01-04 01:32:15
【问题描述】:

我刚刚在 Mac HighSierra 上使用 home-brew 安装了 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 仅针对特定应用程序在我的计算机上录制视频的正确方法是什么?

编辑:在 cmets 中使用 hte 建议,我得到了另一个错误...

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

【问题讨论】:

  • 你读过this吗?没有太多的经验,你的强制工具 (gdigrab) 对我来说只是 Windows。
  • 你是在说 "ffmpeg -f avfoundation -list_devices true -i """ 包含 int aht 链接吗?如果是这样,我编辑了我的问题以包含导致的错误。
  • 你只做了建议步骤的一半。使用获得的信息开始实拍。
  • 我应该使用问题中的什么输出?我收到的“输入/输出错误”是否正常?
  • Input/output error 是正常的,因为您的命令旨在仅列出可用设备。请阅读 sascha 提供的文章并参考avfoundation device documentation

标签: macos video ffmpeg macos-high-sierra


【解决方案1】:

虽然您提到了ffmpeg,但我只是想让您知道,您也可以实现“抓取部分屏幕”的既定目标,而无需安装任何额外的软件,只需使用macOS 预装的工具 - 即 QuickTime,不幸的是,Apple 将其称为 “QuickTime 播放器”,这掩盖了它可以录制和播放的事实。

所以,首先,按 空格QuickTime 进行 “Spotlight 搜索”,然后开始输入“QuickTime”。一旦它猜到你的意思是“QuickTime”,点击 Enter/Return

不去“文件”菜单并点击“新建屏幕录像”。按下红色的“录制”按钮,它会让您拖出一个矩形区域来录制您想要录制的内容。完成后,“停止”按钮位于屏幕右上角靠近时钟的位置。

【讨论】:

  • 澄清一下——我不想捕捉屏幕的真实部分,我只想捕捉一个应用程序的输出。也许是同一件事,但如果我只捕获屏幕的某个部分,并且另一个应用程序落在我想要捕获的屏幕部分之上,那么现在我正在捕获另一个我不想要的应用程序。
  • 如果是这样的话,我想你会对ffmpegQuickTime 感到失望——它们在特定位置记录屏幕,并且不限于单个应用程序.也许您可以详细说明应用程序是什么 - 因为可以诱使某些应用程序生成适合 ffmpeg 的流。
【解决方案2】:

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 兼容性添加了格式过滤器。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-09-03
    • 2021-02-21
    • 1970-01-01
    • 2011-07-26
    • 2018-10-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多