Difference between revisions of "Template:DebianBullseyeDesktop-XFCE-HDMIIN/zh"
From FriendlyELEC WiKi
(updated by API) |
(updated by API) |
||
Line 1: | Line 1: | ||
===HDMI-IN的使用=== | ===HDMI-IN的使用=== | ||
+ | ====使用V4L2命令==== | ||
HDMI-IN 设备的节点为:/dev/video0,可以通过v4l2的命令来操作它。 | HDMI-IN 设备的节点为:/dev/video0,可以通过v4l2的命令来操作它。 | ||
* 获取设备信息 | * 获取设备信息 | ||
Line 55: | Line 56: | ||
--stream-poll | --stream-poll | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | * | + | * 预览图像 |
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
ffplay -f rawvideo -video_size 3840x2160 -pixel_format nv12 4k_nv12.yuv | ffplay -f rawvideo -video_size 3840x2160 -pixel_format nv12 4k_nv12.yuv | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | <!-- | ||
* 使用图形界面预览HDMI-In图像 | * 使用图形界面预览HDMI-In图像 | ||
点击菜单 Multimedia -> Qt V4L2 test Utility,点击 Start Capturing 即可预览图像,配置界面如下图所示:<br /> | 点击菜单 Multimedia -> Qt V4L2 test Utility,点击 Start Capturing 即可预览图像,配置界面如下图所示:<br /> | ||
[[File:T6-debian-hdmiin-v4l2.png|600px]] | [[File:T6-debian-hdmiin-v4l2.png|600px]] | ||
+ | --> | ||
* 查看HDMI-IN音频设备 | * 查看HDMI-IN音频设备 | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
Line 84: | Line 87: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
pi@NanoPC-T6:~$ aplay test.wav -D 'hw:rockchiphdmi0' | pi@NanoPC-T6:~$ aplay test.wav -D 'hw:rockchiphdmi0' | ||
+ | </syntaxhighlight> | ||
+ | ====使用GStreamer==== | ||
+ | * 实时预览 | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | pi@NanoPC-T6:~$ gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,format=NV12,width=3840,height=2160,framerate=60/1 \ | ||
+ | ! queue ! xvimagesink | ||
+ | </syntaxhighlight> | ||
+ | * 音视频录制 | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | pi@NanoPC-T6:~$ gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,format=NV12,width=3840,height=2160,framerate=60/1 \ | ||
+ | ! queue ! mpph265enc ! h265parse ! queue ! mux. alsasrc device=hw:4,0 ! audio/x-raw,channels=2 \ | ||
+ | ! audioconvert ! voaacenc ! queue ! mux. matroskamux name=mux ! filesink location="4kp60.mkv" | ||
+ | </syntaxhighlight> | ||
+ | * 实时预览+音视频录制 | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | pi@NanoPC-T6:~$ gst-launch-1.0 -e v4l2src device=/dev/video0 ! 'video/x-raw,format=NV12,width=3840,height=2160' \ | ||
+ | ! tee name=t t. ! mpph265enc bps=20000000 bps-max=40000000 rc-mode=vbr ! h265parse ! mp4mux name=mux \ | ||
+ | ! filesink location=4k60.mp4 alsasrc device=hw:4,0 ! opusenc ! mux. t. ! queue leaky=1 ! autovideosink sync=false | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 07:56, 18 June 2023
1 HDMI-IN的使用
1.1 使用V4L2命令
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
- 预览图像
ffplay -f rawvideo -video_size 3840x2160 -pixel_format nv12 4k_nv12.yuv
- 查看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'
1.2 使用GStreamer
- 实时预览
pi@NanoPC-T6:~$ gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,format=NV12,width=3840,height=2160,framerate=60/1 \ ! queue ! xvimagesink
- 音视频录制
pi@NanoPC-T6:~$ gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,format=NV12,width=3840,height=2160,framerate=60/1 \ ! queue ! mpph265enc ! h265parse ! queue ! mux. alsasrc device=hw:4,0 ! audio/x-raw,channels=2 \ ! audioconvert ! voaacenc ! queue ! mux. matroskamux name=mux ! filesink location="4kp60.mkv"
- 实时预览+音视频录制
pi@NanoPC-T6:~$ gst-launch-1.0 -e v4l2src device=/dev/video0 ! 'video/x-raw,format=NV12,width=3840,height=2160' \ ! tee name=t t. ! mpph265enc bps=20000000 bps-max=40000000 rc-mode=vbr ! h265parse ! mp4mux name=mux \ ! filesink location=4k60.mp4 alsasrc device=hw:4,0 ! opusenc ! mux. t. ! queue leaky=1 ! autovideosink sync=false