gpt4 book ai didi

linux - Alsa 无法设置样本格式[FFMPEG]

转载 作者:行者123 更新时间:2023-12-04 23:23:03 26 4
gpt4 key购买 nike

我正在尝试使用 ffmpeg 从 Roland USB 设备捕获 pcm 流并用 wav 包装它。我正在使用的命令行如下:

ffmpeg -f alsa -acodec pcm_s32le -ac 2 -ar 48000 -i hw:2,0 out.wav

符合硬件的设置。我还可以使用 Audacity 捕获流。问题是 FFMPEG 抛出 “无法设置样本格式错误” .对可能发生的事情以及如何解决此问题有任何想法吗?

提前致谢。

FFMPEG 输出
user@user:~$ ffmpeg -f alsa -acodec pcm_s32le -ac 2 -ar 48000 -i hw:2,0 out.wav
ffmpeg version N-85548-g3390a2b Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
configuration: --enable-gpl --enable-libx264 --enable-libx265 --enable-libvpx --enable-libvorbis --enable-libopus --enable-ffplay
libavutil 55. 61.100 / 55. 61.100
libavcodec 57. 92.100 / 57. 92.100
libavformat 57. 72.101 / 57. 72.101
libavdevice 57. 7.100 / 57. 7.100
libavfilter 6. 84.101 / 6. 84.101
libswscale 4. 7.101 / 4. 7.101
libswresample 2. 8.100 / 2. 8.100
libpostproc 54. 6.100 / 54. 6.100
[alsa @ 0x34b6780] cannot set sample format 0x10008 10 (Invalid argument)
hw:2,0: Input/output error

记录输出:
user@user:~$ arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: PCH [HDA Intel PCH], device 0: ALC3236 Analog [ALC3236 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: DUOCAPTURE [DUO-CAPTURE], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0

在 Deimus 的帮助下,我在 arecord 中检查了我的卡的设置,并为 FFMPEG 使用了正确的行(请注意,我已经更改了硬件上的捕获频率)。

记录输出
user@user:~$ arecord --dump-hw-params -D hw:2,0
Recording WAVE 'stdin' : Unsigned 8 bit, Rate 8000 Hz, Mono
HW Params of device "hw:2,0":
--------------------
ACCESS: MMAP_INTERLEAVED RW_INTERLEAVED
FORMAT: S24_3LE
SUBFORMAT: STD
SAMPLE_BITS: 24
FRAME_BITS: 48
CHANNELS: 2
RATE: 44100
PERIOD_TIME: (1020 1981429)
PERIOD_SIZE: [45 87381]
PERIOD_BYTES: [270 524286]
PERIODS: [2 1024]
BUFFER_TIME: (2040 3962858)
BUFFER_SIZE: [90 174762]
BUFFER_BYTES: [540 1048572]
TICK_TIME: ALL
--------------------
arecord: set_params:1233: Sample format non available
Available formats:
- S24_3LE

正确的命令行
ffmpeg -f alsa -acodec pcm_s24le -ac 2 -ar 44100 -i hw:2,0 out.wav

最佳答案

使用 --dump-hw-params arecord 的选项检查支持的样本格式的工具。

Man arecord 的页面

然后您可以使用 -sample_fmt ffmpeg 的选项指定格式,例如。 s32
ffmpeg 的音频选项是 here

关于linux - Alsa 无法设置样本格式[FFMPEG],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60938501/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com