マイク入力レベル調整
現在音割れに悩まされているWebカメラ内蔵マイクでの問題解消の一助となれば
サウンドデバイス一覧
root@OpenWrt:~# cat /proc/asound/cards
0 [Audio ]: USB-Audio - AB13X USB Audio
Generic AB13X USB Audio at usb-f2500000.usb-1.4.1, full speed
1 [U4K ]: USB-Audio - UGREEN Camera 4K
Image+ UGREEN Camera 4K at usb-f2500000.usb-1.4.2, high speed
入力レベル調整
設定はコンソール上のGUI
root@OpenWrt:~# alsamixer -c 1 -V capture ┌───────────────────────────── AlsaMixer v1.2.11 ──────────────────────────────┐ │ Card: UGREEN Camera 4K F1: Help │ │ Chip: USB Mixer F2: System information │ │ View: F3: Playback F4:[Capture] F5: All F6: Select sound card │ │ Item: Mic [dB gain: 6.00] Esc: Exit │ │ │ │ ┌──┐ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │▒▒│ │ │ │▒▒│ │ │ │▒▒│ │ │ L└──┘R │ │ CAPTURE │ │ 25 │ │ < Mic > │ │ │ └──────────────────────────────────────────────────────────────────────────────┘
amixer だとCLIのみで設定可能な様である
root@OpenWrt:~# amixer -c0
Simple mixer control 'Mic',0
Capabilities: cvolume cvolume-joined cswitch cswitch-joined
Capture channels: Mono
Limits: Capture 0 - 24
Mono: Capture 8 [33%] [8.00dB] [on]
root@OpenWrt:~# amixer -c0 contents
numid=2,iface=MIXER,name='Mic Capture Switch'
; type=BOOLEAN,access=rw------,values=1
: values=on
numid=3,iface=MIXER,name='Mic Capture Volume'
; type=INTEGER,access=rw---R--,values=1,min=0,max=24,step=0
: values=8
| dBminmax-min=0.00dB,max=24.00dB
numid=1,iface=PCM,name='Capture Channel Map'
; type=INTEGER,access=r--v-R--,values=2,min=0,max=36,step=0
: values=0,0
| container
| chmap-fixed=FL,FR
root@OpenWrt:~# amixer -c0 set Mic 4dB unmute
Simple mixer control 'Mic',0
Capabilities: cvolume cvolume-joined cswitch cswitch-joined
Capture channels: Mono
Limits: Capture 0 - 24
Mono: Capture 4 [17%] [4.00dB] [on]
root@OpenWrt:~# amixer -c0
Simple mixer control 'Mic',0
Capabilities: cvolume cvolume-joined cswitch cswitch-joined
Capture channels: Mono
Limits: Capture 0 - 24
Mono: Capture 4 [17%] [4.00dB] [on]
入力レベルを含む設定出力
特定のサウンドデバイスのみ指定する場合は store の後ろに数字を付ける
root@OpenWrt:~# alsactl -f /mnt/alsa.cfg store 1
root@OpenWrt:~# cat /mnt/alsa.cfg
state.U4K {
control.1 {
iface PCM
name 'Capture Channel Map'
value.0 0
value.1 0
comment {
access 'read volatile'
type INTEGER
count 2
range '0 - 36'
}
}
control.2 {
iface MIXER
name 'Mic Capture Switch'
value true
comment {
access 'read write'
type BOOLEAN
count 1
}
}
control.3 {
iface MIXER
name 'Mic Capture Volume'
value 6
comment {
access 'read write'
type INTEGER
count 1
range '0 - 24'
dbmin 0
dbmax 2400
dbvalue.0 600
}
}
}
入力レベルを含む設定復元
root@OpenWrt:~# alsactl -f /mnt/alsa.cfg restore 1
ffmpegによるalsaデバイスに対する volumedetect
max_volume は最大値が 0.0 dB らしく、音割れする場合もその値で出るので、たぶんマイナス域から調整した方が良い
root@OpenWrt:~# ffmpeg -f alsa -i hw:1 -vn -af volumedetect -f null -
ffmpeg version 6.1.3 Copyright (c) 2000-2025 the FFmpeg developers
built with gcc 14.3.0 (OpenWrt GCC 14.3.0 r31873-9d2882f3c0)
configuration: --enable-cross-compile --cross-prefix=aarch64-openwrt-linux-musl- --arch=aarch64 --cpu=cortex-a72 --target-os=linux --prefix=/usr --pkg-config=pkg-config --enable-shared --enable-static --enable-pthreads --enable-zlib --disable-doc --disable-debug --disable-lzma --disable-vaapi --disable-vdpau --disable-outdevs --disable-runtime-cpudetect --enable-lto --enable-neon --enable-vfp --disable-x86asm --enable-gnutls --disable-decoder=atrac3 --disable-decoder=h264 --disable-decoder=hevc --disable-decoder=vc1 --disable-muxer=h264 --disable-muxer=hevc --disable-muxer=vc1 --disable-demuxer=h264 --disable-demuxer=hevc --disable-demuxer=vc1 --disable-parser=h264 --disable-parser=hevc --disable-parser=vc1 --enable-libv4l2 --enable-small --enable-libmp3lame --enable-libfdk-aac
libavutil 58. 29.100 / 58. 29.100
libavcodec 60. 31.102 / 60. 31.102
libavformat 60. 16.100 / 60. 16.100
libavdevice 60. 3.100 / 60. 3.100
libavfilter 9. 12.100 / 9. 12.100
libswscale 7. 5.100 / 7. 5.100
libswresample 4. 12.100 / 4. 12.100
[aist#0:0/pcm_s16le @ 0x7fa7e87020] Guessed Channel Layout: stereo
Input #0, alsa, from 'hw:1':
Duration: N/A, start: 1764088156.854518, bitrate: 1536 kb/s
Stream #0:0: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s
[Parsed_volumedetect_0 @ 0x7fa7e97e50] n_samples: 0
Stream mapping:
Stream #0:0 -> #0:0 (pcm_s16le (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, null, to 'pipe:':
Metadata:
encoder : Lavf60.16.100
Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Metadata:
encoder : Lavc60.31.102 pcm_s16le
[out#0/null @ 0x7fa7e95cc0] video:0kB audio:9583kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
size=N/A time=00:00:51.10 bitrate=N/A speed= 1x
[Parsed_volumedetect_0 @ 0x7fa7db1020] n_samples: 4906612
[Parsed_volumedetect_0 @ 0x7fa7db1020] mean_volume: -37.9 dB
[Parsed_volumedetect_0 @ 0x7fa7db1020] max_volume: -1.3 dB
[Parsed_volumedetect_0 @ 0x7fa7db1020] histogram_1db: 10
[Parsed_volumedetect_0 @ 0x7fa7db1020] histogram_2db: 98
[Parsed_volumedetect_0 @ 0x7fa7db1020] histogram_3db: 96
[Parsed_volumedetect_0 @ 0x7fa7db1020] histogram_4db: 68
[Parsed_volumedetect_0 @ 0x7fa7db1020] histogram_5db: 128
[Parsed_volumedetect_0 @ 0x7fa7db1020] histogram_6db: 134
[Parsed_volumedetect_0 @ 0x7fa7db1020] histogram_7db: 160
[Parsed_volumedetect_0 @ 0x7fa7db1020] histogram_8db: 200
[Parsed_volumedetect_0 @ 0x7fa7db1020] histogram_9db: 342
[Parsed_volumedetect_0 @ 0x7fa7db1020] histogram_10db: 478
[Parsed_volumedetect_0 @ 0x7fa7db1020] histogram_11db: 444
[Parsed_volumedetect_0 @ 0x7fa7db1020] histogram_12db: 670
[Parsed_volumedetect_0 @ 0x7fa7db1020] histogram_13db: 844
[Parsed_volumedetect_0 @ 0x7fa7db1020] histogram_14db: 950
[Parsed_volumedetect_0 @ 0x7fa7db1020] histogram_15db: 802
Exiting normally, received signal 2.