我想在我的 ffmpeg cli 中添加音频
ffmpeg -framerate 25 -video_size 1920x1080 -f x11grab -i :0.0 -vf format=yuv420p http://localhost:8080/feed.ffm
编辑
arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: Intel [HDA Intel], device 0: ALC883 Analog [ALC883 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 2: ALC883 Alt Analog [ALC883 Alt Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
这是 -L
arecord -L
default
Playback/recording through the PulseAudio sound server
null
Discard all samples (playback) or generate zero samples (capture)
pulse
PulseAudio Sound Server
sysdefault:CARD=Intel
HDA Intel, ALC883 Analog
Default Audio Device
front:CARD=Intel,DEV=0
HDA Intel, ALC883 Analog
Front speakers
dmix:CARD=Intel,DEV=0
HDA Intel, ALC883 Analog
Direct sample mixing device
dmix:CARD=Intel,DEV=2
HDA Intel, ALC883 Alt Analog
Direct sample mixing device
dsnoop:CARD=Intel,DEV=0
HDA Intel, ALC883 Analog
Direct sample snooping device
dsnoop:CARD=Intel,DEV=2
HDA Intel, ALC883 Alt Analog
Direct sample snooping device
hw:CARD=Intel,DEV=0
HDA Intel, ALC883 Analog
Direct hardware device without any conversions
hw:CARD=Intel,DEV=2
HDA Intel, ALC883 Alt Analog
Direct hardware device without any conversions
plughw:CARD=Intel,DEV=0
HDA Intel, ALC883 Analog
Hardware device with all software conversions
plughw:CARD=Intel,DEV=2
HDA Intel, ALC883 Alt Analog
Hardware device with all software conversions
答案1
您必须提供音频输入。假设您想要桌面/“您听到的”/“立体声混音”声音,最简单的方法是使用 pavucontrol 选择要录制的内容,然后使用PulseAudio 输入在ffmpeg
。
帕武控制
看使用 ffmpeg 捕获桌面音频以使用 pavucontrol。
或者使用pactl list sources
如果您不想使用 pavucontrol,请使用以下命令列出音频源pactl list sources
:
$ pactl list sources | grep monitor
Name: alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1.monitor
device.class = "monitor"
Name: alsa_output.pci-0000_00_1b.0.analog-stereo.monitor
device.class = "monitor"
然后运行ffmpeg
:
ffmpeg -framerate 25 -video_size 1920x1080 -f x11grab -i :0.0 -f pulse -i alsa_output.pci-0000_00_1b.0.analog-stereo.monitor -c:v libx264 -c:a aac -vf format=yuv420p http://localhost:8080/feed.ffm