Skip to content

captureHdmiAudio

Tobias Kammacher edited this page Apr 7, 2017 · 3 revisions

Capture Audio from HDMI Input

Currently (L4T R24.2.1@dd13899) it is possible to capture audio, but only with these limitations:

  • Only on HDMI-In-B
  • Max. 2 channels (stereo)
  • You need to connect some headers with wires

The HDMI-In A is fixed connected to I2S4 through the camera connector on the Jetson TX1 board. We have not yet found a way to use I2S4. But for HDMI-In B the I2S connections are connected to a 0.1" header (X501) on the HDMI2CSI board. These pins can be connected to I2S1 which is available on J21 header of the Jetson.

To capture stereo audio on HDMI-In-B follow these steps:

Connect the I2S pins

Use wires to connect the 4 pins of the I2S interface (GND, CLK, OUT, LRC) from the X501 connector on the HDMI2CSI board to the J21 header of the Jetson board. Make sure to twist the wires to reduce EMI. (Optimal is to twist each signal with a ground wire) hdmi2csi-audio-hdmi-b.png

Example for twisted wires

hdmi2csi-audio-twisted-wires.jpg

Commands to enable audio capturing

First we need to export some GPIOs to make them available for user space:

echo 8 > /sys/class/gpio/export #LRC 
echo 9 > /sys/class/gpio/export #Data in
echo 11 > /sys/class/gpio/export #SCLK
echo 8 > /sys/class/gpio/unexport
echo 9 > /sys/class/gpio/unexport
echo 11 > /sys/class/gpio/unexport

Load the driver for the tc358840 bridge IC:

sudo modprobe tc358840

Start a video capturing pipeline on /dev/video2 (e.g.):

gst-launch-1.0 v4l2src device=/dev/video2 ! 'video/x-raw, width=1920, height=1080, framerate=60/1, format=UYVY' ! nvvidconv ! 'video/x-raw(memory:NVMM), format=I420' ! nvoverlaysink

Record audio on the ALSA device 1,0 (e.g. use arecord):

arecord -f S16_LE -c 2 -r 48000 -d 5 -D hw:1,0 test.wav

Note that in the EDID currently the following Audio settings are allowed:

  • Format = Linear PCM
  • Format = Uncompressed, 16 Bit
  • Number of Channels = 2
  • Supported Sampling Frequencies
    • 32 kHz
    • 44 kHz
    • 48 kHz

Therefore your HDMI source has a choice of which sampling frequency it may deliver. Currently there is not yet a mechanism in the drivers to determine which sampling frequency was chosen by the source.