我尝试在 mac 上使用 ffmpeg 录制屏幕以及传入音频,但在输入设备列表中,没有“扬声器”。有没有办法获取输出音频?
$ ffmpeg -f avfoundation -list_devices true -i ""
configuration: --prefix=/usr/local --enable-gpl --enable-nonfree --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid
libavutil 55. 18.100 / 55. 18.100
libavcodec 57. 24.105 / 57. 24.105
libavformat 57. 26.100 / 57. 26.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 34.100 / 6. 34.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
[AVFoundation input device @ 0x7fd5f9600360] AVFoundation video devices:
[AVFoundation input device @ 0x7fd5f9600360] [0] FaceTime HD Camera
[AVFoundation input device @ 0x7fd5f9600360] [1] Capture screen 0
[AVFoundation input device @ 0x7fd5f9600360] [2] Capture screen 1
[AVFoundation input device @ 0x7fd5f9600360] AVFoundation audio devices:
[AVFoundation input device @ 0x7fd5f9600360] [0] Soundflower (2ch)
[AVFoundation input device @ 0x7fd5f9600360] [1] Built-in Microphone
[AVFoundation input device @ 0x7fd5f9600360] [2] Soundflower (64ch)
: Input/output error
最佳答案
“扬声器”音频是您的系统音频 - 什么 Soundflower允许您访问。
鉴于Soundflower选项被识别为 AV Foundation音频设备并显示在 ffmpeg -f avfoundation -list_devices true -i ""
生成的输出中命令,桌面的基本捕获([1] Capture screen 0
)和立体声系统声音([0] Soundflower (2ch)
)将是:
ffmpeg -f avfoundation -i "1:0"Screen.mov
请注意,“1:0”
是“[1] 捕获屏幕 0:[0] Soundflower (2ch)”
我怀疑您的音频听起来不好的原因是位深度差异。我的 Mac 默认音频设置为 24 位。每FFmpeg's audio documentation :
ffmpeg-sample_fmts
表示 ffmpeg 有以下可用格式和位深度:
u8 8
s16 16
s32 32
flt 32
dbl 64
u8p 8
s16p 16
s32p 32
fltp 32
dblp 64
s64 64
s64p 64
...我在那里没有看到 24。您的录音听起来可能很差,因为位被截断。
正如 Sarge Borsch 所说,您的音频 Midi 设置将向您显示位深度和采样频率,并为您提供一些选项。您可以在 Audio Midi Setup.app >> Audio Devices::Built-in Output::Format 中更改“扬声器”,直到找到有效的东西,或者您可以在 FFmpeg 行命令中指定位深度以匹配您的设置。据我所知 FFmpeg 将默认为源的位深度。请注意,在 Audio Midi Setup.app 中,您的“系统音频”设备将由 Finder 图标和扬声器图标指示 - 我通过 Thunderbolt 端口使用外部显示器,“系统”音频将路由到该设备,而不是内置设备在扬声器中。因此,根据您的配置,只需将音频位深度更改为 16 即可使用基本捕获语法:
ffmpeg -f avfoundation -i "1:0"Screen.mov
值得注意的是,ffmpeg 确实可以处理 24 位 PCM 音频:
$ ffmpeg -formats | grep PCM | grep 24
DE s24be PCM signed 24-bit big-endian
DE s24le PCM signed 24-bit little-endian
DE u24be PCM unsigned 24-bit big-endian
DE u24le PCM unsigned 24-bit little-endian
关于Mac 的 FFMPEG 录制输出音频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35590500/