Xubuntu 18.04では、ffmpegコマンドを使用してALSAループバックがシステムオーディオを録音しません。

Xubuntu 18.04では、ffmpegコマンドを使用してALSAループバックがシステムオーディオを録音しません。

スクリーンキャストを撮るffmpegスクリプトがあります。オフィスにはDebian 9があり、家にはXubuntu 18.04があります。両方のオペレーティングシステムで、以下はマイマイクのシステムオーディオを録音するのに役立ちます。

    pacmd set-default-source alsa_output.pci-0000_00_14.2.analog-stereo.monitor
    ffmpeg \
    -thread_queue_size 4096 -f alsa -ac 1 -ar 48000 -i default \
    -thread_queue_size 4096 -f alsa -ac 1 -ar 48000 -i plughw:CARD=Device,DEV=0 \
    -filter_complex amix=inputs=2 \
    -thread_queue_size 4096 -f x11grab -r 30 -s 1920x1080 -i $DISPLAY+1920,0 \
    -c:v libx264 -crf 20 -preset veryfast \
    -c:a aac -ac 2 -b:a 192k \
    -pix_fmt yuv420p -movflags faststart \
    ~/Desktop/out.mp4

これは、Pulseの「内蔵オーディオモニタ」を使用してデスクトップオーディオをキャプチャします。残念ながら、Debian 10、Xubuntu 19.04、19.10、Fedora 30では画面の録画を終了して押してもq正常に停止しません。停止します。その後、プロンプトに戻るには、Ctrl + Cを数回使用する必要があります。私のスクリプトは終了し、必要な次のコマンドは実行されません。機会になると、このバグを報告します。これがALSAバグかPulseバグかはわかりません。 Debian 9とDebian 10の両方に同じffmpegバージョンがあり、Debian 9ではなくDebian 10でのみ発生するため、これはffmpegのバグだとは思わない。

私はLenovo ThinkCentreを使用しています。フロントとリアのオーディオ出力とマイク用の3.5mmジャックがあります。 3.5mmケーブルを使用してオーディオをマイクジャックに再ルーティングします。動作しますが、オーディオ品質が悪いです。これを行うには-f alsa -i plughw:CARD=Generic,DEV=0ffmpegコマンドで使用しました。 ALSA デバイス名を使用すると、Xubuntu 19.10 などで中断されません。

だから私はALSAループバックデバイスを使ってシステムオーディオを録音しようとしてきました。とても書けませんでした。起動時にカーネルモジュールをロードしますsnd-aloop~/.asoundrcページ下部でさまざまな設定オプションを試しました。ここそしてここ。これが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=Loopback
    Loopback, Loopback PCM
    Default Audio Device
front:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    Front speakers
surround21:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    4.0 Surround output to Front and Rear speakers
surround41:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
dmix:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    Direct sample mixing device
dmix:CARD=Loopback,DEV=1
    Loopback, Loopback PCM
    Direct sample mixing device
dsnoop:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    Direct sample snooping device
dsnoop:CARD=Loopback,DEV=1
    Loopback, Loopback PCM
    Direct sample snooping device
hw:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    Direct hardware device without any conversions
hw:CARD=Loopback,DEV=1
    Loopback, Loopback PCM
    Direct hardware device without any conversions
plughw:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    Hardware device with all software conversions
plughw:CARD=Loopback,DEV=1
    Loopback, Loopback PCM
    Hardware device with all software conversions
sysdefault:CARD=Generic
    HD-Audio Generic, ALC662 rev3 Analog
    Default Audio Device
front:CARD=Generic,DEV=0
    HD-Audio Generic, ALC662 rev3 Analog
    Front speakers
dmix:CARD=Generic,DEV=0
    HD-Audio Generic, ALC662 rev3 Analog
    Direct sample mixing device
dmix:CARD=Generic,DEV=2
    HD-Audio Generic, ALC662 rev3 Alt Analog
    Direct sample mixing device
dsnoop:CARD=Generic,DEV=0
    HD-Audio Generic, ALC662 rev3 Analog
    Direct sample snooping device
dsnoop:CARD=Generic,DEV=2
    HD-Audio Generic, ALC662 rev3 Alt Analog
    Direct sample snooping device
hw:CARD=Generic,DEV=0
    HD-Audio Generic, ALC662 rev3 Analog
    Direct hardware device without any conversions
hw:CARD=Generic,DEV=2
    HD-Audio Generic, ALC662 rev3 Alt Analog
    Direct hardware device without any conversions
plughw:CARD=Generic,DEV=0
    HD-Audio Generic, ALC662 rev3 Analog
    Hardware device with all software conversions
plughw:CARD=Generic,DEV=2
    HD-Audio Generic, ALC662 rev3 Alt Analog
    Hardware device with all software conversions
sysdefault:CARD=Device
    USB PnP Audio Device, USB Audio
    Default Audio Device
front:CARD=Device,DEV=0
    USB PnP Audio Device, USB Audio
    Front speakers
surround21:CARD=Device,DEV=0
    USB PnP Audio Device, USB Audio
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=Device,DEV=0
    USB PnP Audio Device, USB Audio
    4.0 Surround output to Front and Rear speakers
surround41:CARD=Device,DEV=0
    USB PnP Audio Device, USB Audio
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Device,DEV=0
    USB PnP Audio Device, USB Audio
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Device,DEV=0
    USB PnP Audio Device, USB Audio
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Device,DEV=0
    USB PnP Audio Device, USB Audio
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=Device,DEV=0
    USB PnP Audio Device, USB Audio
    IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=Device,DEV=0
    USB PnP Audio Device, USB Audio
    Direct sample mixing device
dsnoop:CARD=Device,DEV=0
    USB PnP Audio Device, USB Audio
    Direct sample snooping device
hw:CARD=Device,DEV=0
    USB PnP Audio Device, USB Audio
    Direct hardware device without any conversions
plughw:CARD=Device,DEV=0
    USB PnP Audio Device, USB Audio
    Hardware device with all software conversions
sysdefault:CARD=U0x46d0x825
    USB Device 0x46d:0x825, USB Audio
    Default Audio Device
front:CARD=U0x46d0x825,DEV=0
    USB Device 0x46d:0x825, USB Audio
    Front speakers
surround21:CARD=U0x46d0x825,DEV=0
    USB Device 0x46d:0x825, USB Audio
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=U0x46d0x825,DEV=0
    USB Device 0x46d:0x825, USB Audio
    4.0 Surround output to Front and Rear speakers
surround41:CARD=U0x46d0x825,DEV=0
    USB Device 0x46d:0x825, USB Audio
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=U0x46d0x825,DEV=0
    USB Device 0x46d:0x825, USB Audio
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=U0x46d0x825,DEV=0
    USB Device 0x46d:0x825, USB Audio
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=U0x46d0x825,DEV=0
    USB Device 0x46d:0x825, USB Audio
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=U0x46d0x825,DEV=0
    USB Device 0x46d:0x825, USB Audio
    IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=U0x46d0x825,DEV=0
    USB Device 0x46d:0x825, USB Audio
    Direct sample mixing device
dsnoop:CARD=U0x46d0x825,DEV=0
    USB Device 0x46d:0x825, USB Audio
    Direct sample snooping device
hw:CARD=U0x46d0x825,DEV=0
    USB Device 0x46d:0x825, USB Audio
    Direct hardware device without any conversions
plughw:CARD=U0x46d0x825,DEV=0
    USB Device 0x46d:0x825, USB Audio
    Hardware device with all software conversions

リストされたループバックデバイスを使用して、次のテストを実行しました。再生中のオーディオが下に録音されていません。

ffmpeg -f alsa -i loopin -t 10 1.wav
ffmpeg -f alsa -i loopout -t 10 2.wav
ffmpeg -f alsa -i sysdefault:CARD=Loopback -t 10 3.wav
ffmpeg -f alsa -i front:CARD=Loopback,DEV=0 -t 10 4.wav
ffmpeg -f alsa -i surround21:CARD=Loopback,DEV=0 -t 10 5.wav
ffmpeg -f alsa -i surround40:CARD=Loopback,DEV=0 -t 10 6.wav
ffmpeg -f alsa -i surround41:CARD=Loopback,DEV=0 -t 10 7.wav
ffmpeg -f alsa -i surround50:CARD=Loopback,DEV=0 -t 10 8.wav
ffmpeg -f alsa -i surround51:CARD=Loopback,DEV=0 -t 10 9.wav
ffmpeg -f alsa -i surround71:CARD=Loopback,DEV=0 -t 10 10.wav
ffmpeg -f alsa -i dmix:CARD=Loopback,DEV=0 -t 10 11.wav
ffmpeg -f alsa -i dmix:CARD=Loopback,DEV=1 -t 10 12.wav
ffmpeg -f alsa -i dsnoop:CARD=Loopback,DEV=0 -t 10 13.wav
ffmpeg -f alsa -i dsnoop:CARD=Loopback,DEV=1 -t 10 14.wav
ffmpeg -f alsa -i hw:CARD=Loopback,DEV=0 -t 10 15.wav
ffmpeg -f alsa -i hw:CARD=Loopback,DEV=1 -t 10 16.wav
ffmpeg -f alsa -i plughw:CARD=Loopback,DEV=0 -t 10 17.wav
ffmpeg -f alsa -i plughw:CARD=Loopback,DEV=1 -t 10 18.wav

pavucontrolループバックデバイスがリストされていないことがわかりました。だから、次のコマンドを実行しましたpactl load-module module-loopback。 「再生」タブにのみ表示され、他のタブには表示されません。私はこれらすべてをXubuntu 18.04でテストしましたが、Xubuntu 19.10もインストールしました。

過去にはパルスデバイス、つまりでffmpegを使ってみましたpacmd list-sources。これにより、録音されたシステムオーディオが1〜2秒遅れました。

ベストアンサー1

これは私にとって効果的です。

ffmpeg -f alsa -ac 1 -i dsnoop:CARD=USB,DEV=0 -acodec mp3 -y ~/recording/$(date +"%Y-%m-%d_%H:%M").mp3

ループバックの代わりに物理デバイスを指すdsnoopエントリの1つを使用することは重要ですが、わかりません。

おすすめ記事