USB Mic Not Detected in Jetson Container on Orin Nano (Pyaudio issue)

I’m experiencing an issue with a container running on my Jetson Orin Nano where my USB webcam microphone is not recognized by PyAudio, even though it works on the host.

Environment:

  • Hardware: Jetson Orin Nano
  • Container: Launched with jetson-containers run --privileged pcdemo:r36.4.3
  • Host OS: Ubuntu (with standard ALSA configuration)
  • Audio Libraries: PyAudio (using PortAudio), ALSA

The Problem:

  • On the Host:
    • Running arecord -l shows my USB mic as card 0.
    • I can verify the device node exists (e.g., /dev/snd/pcmC0D0c).
  • Inside the Container:
    • Running a PyAudio device enumeration script:

python

Copy

import pyaudio
p = pyaudio.PyAudio()
for i in range(p.get_device_count()):
    dev = p.get_device_info_by_index(i)
    if dev.get('maxInputChannels', 0) > 0:
        print(f"Input Device {i}: {dev['name']} (ID: {dev['index']})")
p.terminate()

only lists built-in NVIDIA devices (e.g., NVIDIA Jetson Orin Nano APE: - (hw:2,0) and so on). The USB mic is not shown.

  • Attempting to record directly using:

bash

Copy

arecord -D plughw:0,0 -f cd -d 5 test.wav

returns:

lua

Copy

arecord: main:831: audio open error: Device or resource busy

Yet, both lsof /dev/snd/pcmC0D0c and fuser /dev/snd/pcmC0D0c return no processes using the device.

Steps I’ve Taken:

  1. ALSA Verification:
  • Confirmed the USB mic appears as card 0 on the host.
  • Verified the device node exists and appears to have correct permissions.
  1. ALSA Configuration Adjustment:
  • Created/modified /etc/asound.conf in the container with:

conf

Copy

pcm.!default {
    type plug
    slave {
        pcm "hw:0,0"
    }
}
ctl.!default {
    type hw
    card 0
}
  • Despite this, PyAudio continues to list only the NVIDIA devices.
  1. Container Privileges:
  • The container is started with --privileged to allow full device access.

My Suspicions:

  • It seems that ALSA (and by extension PortAudio/PyAudio) defaults to the built‑in NVIDIA audio interfaces rather than the USB mic, even though the USB mic works on the host.
  • The “device busy” error from arecord might indicate a conflict at the ALSA/driver level within the container.
  • There may be an issue with how the container’s environment or ALSA configuration is set up on the Jetson platform that prevents the USB mic from being selected as the default capture device.

Hi,
There is a similar use-case:
Gst-launch-1.0 -vv alsasrc ! alsasink does not work in docker - #9 by DaneLLL

Please take a look and give it a try.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.