Template:DebianBullseyeDesktop-XFCE-HDMIIN/zh
From FriendlyELEC WiKi
HDMI-IN的使用
HDMI-IN 设备的节点为:/dev/video0,可以通过v4l2的命令来操作它。
- 获取设备信息
pi@NanoPC-T6:~$ v4l2-ctl -d /dev/video0 -V -D Driver Info: Driver name : rk_hdmirx Card type : rk_hdmirx Bus info : fdee0000.hdmirx-controller Driver version : 5.10.110 Capabilities : 0x84201000 Video Capture Multiplanar Streaming Extended Pix Format Device Capabilities Device Caps : 0x04201000 Video Capture Multiplanar Streaming Extended Pix Format Format Video Capture Multiplanar: Width/Height : 3840/2160 Pixel Format : 'NV12' (Y/CbCr 4:2:0) Field : None Number of planes : 1 Flags : premultiplied-alpha, 0x000000fe Colorspace : Unknown (0x11507070) Transfer Function : Unknown (0x000000b8) YCbCr/HSV Encoding: Unknown (0x000000ff) Quantization : Default Plane 0 : Bytes per Line : 3840 Size Image : 12441600
- 查看当前连接的设备的分辨率与图像格式
pi@NanoPC-T6:~$ v4l2-ctl -d /dev/video0 --get-fmt-video Format Video Capture Multiplanar: Width/Height : 3840/2160 Pixel Format : 'NV12' (Y/CbCr 4:2:0) Field : None Number of planes : 1 Flags : premultiplied-alpha, 0x000000fe Colorspace : Unknown (0x1193b008) Transfer Function : Unknown (0x000000b8) YCbCr/HSV Encoding: Unknown (0x000000ff) Quantization : Default Plane 0 : Bytes per Line : 3840 Size Image : 12441600
- 获取一帧图像
pi@NanoPC-T6:~$ v4l2-ctl -d /dev/video0 --set-fmt-video=width=3840,height=2160,pixelformat='NV12' \ --stream-mmap=4 --stream-skip=10 --stream-to=/home/pi/4k_nv12.yuv --stream-count=1 \ --stream-poll
- 在电脑上预览 (Linux/Mac)
ffplay -f rawvideo -video_size 3840x2160 -pixel_format nv12 4k_nv12.yuv
- 使用图形界面预览HDMI-In图像
点击菜单 Multimedia -> Qt V4L2 test Utility,点击 Start Capturing 即可预览图像,配置界面如下图所示:
- 查看HDMI-IN音频设备
pi@NanoPC-T6:~$ cat /proc/asound/card* 0 [rockchipdp0 ]: rockchip_dp0 - rockchip,dp0 rockchip,dp0 1 [rockchiphdmi0 ]: rockchip_hdmi0 - rockchip,hdmi0 rockchip,hdmi0 2 [realtekrt5616co]: realtek_rt5616- - realtek,rt5616-codec realtek,rt5616-codec 3 [rockchiphdmi1 ]: rockchip_hdmi1 - rockchip,hdmi1 rockchip,hdmi1 4 [rockchiphdmiin ]: rockchip_hdmiin - rockchip,hdmiin rockchip,hdmiin
可以看到,rockchiphdmiin的声卡号为4
- 录制音频(录制10秒)
pi@NanoPC-T6:~$ arecord -D hw:4,0 -f cd test.wav -d 10
- 回放所录制的音频(输出到HDMI0)
pi@NanoPC-T6:~$ aplay test.wav -D 'hw:rockchiphdmi0'