继ffmpeg 的捕获桌面指南对于 Linux,当音频源为脉冲格式时,会导致帧冻结和不同步、fps 减慢,并且视频与音频相比会出现延迟。
我尝试了在研究中发现的几种参数组合,试图解决此问题,以下是我当前使用的命令:
ffmpeg \
-video_size 1920x1080 \
-framerate 60 \
-f x11grab \
-probesize 42M \
-thread_queue_size 64 \
-i :0.0 \
-f pulse \
-thread_queue_size 64 \
-i default \
-c:v libx264rgb \
-crf 0 \
-preset ultrafast \
-c:a aac \
-ac 2 \
-b:a 160k \
-ar 44100 \
-strict experimental \
-threads 8 \
-vsync vfr \
-max_muxing_queue_size 64 \
-f mp4 \
-y o.mp4
但有趣的事实是,如果我更换音频源,-f alsa -i pulse
它就会工作并且出现警告消息“100 个缓冲区在 out_0_1 中排队,可能出现问题。“ 离开了。
我正在使用的版本4.2.4-1ubuntu0.1,由于脉冲更加通用,允许通过应用程序和自定义模块控制音量,我希望 ffmpeg 能够与脉冲一起正常工作。
证据:https://youtu.be/rhjfQNd5lP4
这是我的默认来源 ( pactl list sources
):
Source #1
State: SUSPENDED
Name: alsa_input.pci-0000_27_00.3.analog-stereo
Description: Family 17h (Models 00h-0fh) HD Audio Controller Estéreo analógico
Driver: module-alsa-card.c
Sample Specification: s16le 2ch 48000Hz
Channel Map: front-left,front-right
Owner Module: 9
Mute: no
Volume: front-left: 19661 / 30% / -31.37 dB, front-right: 19661 / 30% / -31.37 dB
balance 0.00
Base Volume: 6554 / 10% / -60.00 dB
Monitor of Sink: n/a
Latency: 0 usec, configured 0 usec
Flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY
Properties:
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = "ALC892 Analog"
alsa.id = "ALC892 Analog"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "0"
alsa.card = "1"
alsa.card_name = "HD-Audio Generic"
alsa.long_card_name = "HD-Audio Generic at 0xfe800000 irq 69"
alsa.driver_name = "snd_hda_intel"
device.bus_path = "pci-0000:27:00.3"
sysfs.path = "/devices/pci0000:00/0000:00:08.1/0000:27:00.3/sound/card1"
device.bus = "pci"
device.vendor.id = "1022"
device.vendor.name = "Advanced Micro Devices, Inc. [AMD]"
device.product.id = "1457"
device.product.name = "Family 17h (Models 00h-0fh) HD Audio Controller"
device.string = "front:1"
device.buffering.buffer_size = "17664"
device.buffering.fragment_size = "2944"
device.access_mode = "mmap"
device.profile.name = "analog-stereo"
device.profile.description = "Estéreo analógico"
device.description = "Family 17h (Models 00h-0fh) HD Audio Controller Estéreo analógico"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-pci"
Ports:
analog-input-front-mic: Microfone frontal (priority: 8500, available)
analog-input-rear-mic: Microfone traseiro (priority: 8200, not available)
analog-input-linein: Entrada de linha (priority: 8100, not available)
Active Port: analog-input-front-mic
Formats:
pcm
由于我不知道这个问题是否是由于我的声卡或缺少 ffmpeg 设置造成的,您能否尝试一下我尝试过的命令,并反馈我是否对您有用?如果您有任何想法我可以尝试使其发挥作用,请帮助我。