Encoding from HDMI Rx

It is possible to encode audio and video received via the HDMI Rx port. This is possible using an extension of the hdmirx-capture application (see HDMI Receive for more info) that has been developed for demonstration purposes.

Setup

As with the simple HDMI passthrough example, it is necessary to use media-ctl to configure the audio and video paths before we can encode the input:

# disable audio/video local playback to Main-VID/Mixer
media-ctl -l '"dvb0.video0":0->"Main-VID":0[0]'
media-ctl -l '"dvb0.audio0":0->"mixer0":0[0]'

# create audio path
media-ctl -l '"v4l2.audio0":1->"mixer0":0[1]'
media-ctl -l '"hdmirx0":2->"v4l2.audio0":0[1]'

# create video path
media-ctl -l '"v4l2.video0":1->"Main-VID":0[1]'
media-ctl -l '"hdmirx0":1->"dvp0":0[1]'
media-ctl -l '"dvp0":1->"v4l2.video0":0[1]'

# connect the audio decoder directly to the audio encoder
media-ctl -l '"v4l2.audio0":1->"aud-encoder-00":0[1]'

# create compositor capture path
media-ctl -l '"analog_hdout0":1->"compo-capture0":0[1]'
media-ctl -l '"compo-capture0":1->"STM Compo Capture":0[1]'


If you are using Raspbian, you will also need to hide the desktop by making the graphics plane transparent:

stfbset -a 0

Encode

It is now possible to use hdmirx-capture to enable the passthrough (as before), but also encode the composited audio and video using the --encode flag.

hdmirx-capture --dec-id=0 --dvp-start --vid-capture-profile=2 --debug --encode /tmp/video.ts

The output will be a transport stream with audio encoded using AAC, and video encoded using h.264 at around 4Mbit/s.

Teardown

Once you're done, you may want to teardown the pipelines:

# disable compositor capture path
media-ctl -l '"analog_hdout0":1->"compo-capture0":0[0]'
media-ctl -l '"compo-capture0":1->"STM Compo Capture":0[0]'

# disconnect the audio decoder directly to the audio encoder
media-ctl -l '"v4l2.audio0":1->"aud-encoder-00":0[0]'

# teardown the video path
media-ctl -l '"v4l2.video0":1->"Main-VID":0[0]'
media-ctl -l '"hdmirx0":1->"dvp0":0[0]'
media-ctl -l '"dvp0":1->"v4l2.video0":0[0]'

# teardown the audio path
media-ctl -l '"v4l2.audio0":1->"mixer0":0[0]'
media-ctl -l '"hdmirx0":2->"v4l2.audio0":0[0]'

# enable audio/video local playback to Main-VID/Mixer
media-ctl -l '"dvb0.video0":0->"Main-VID":0[1]'
media-ctl -l '"dvb0.audio0":0->"mixer0":0[1]'


If you're using Raspbian, you should then unhide the desktop by making the graphics plane opaque again.

stfbset -a 255