Difference between revisions of "Template:DebianBullseyeDesktop-XFCE-HDMIIN/zh"
From FriendlyELEC WiKi
(updated by API) |
(updated by API) |
||
Line 57: | Line 57: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
* 预览图像 | * 预览图像 | ||
+ | 使用ffplay: | ||
<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> | ||
+ | 使用mpv: | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | mpv 4k_nv12.yuv --demuxer=rawvideo --demuxer-rawvideo-w=3840 --demuxer-rawvideo-h=2160 \ | ||
+ | --demuxer-rawvideo-mp-format=nv12 --demuxer-rawvideo-fps=60 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<!-- | <!-- |
Revision as of 15:50, 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:
ffplay -f rawvideo -video_size 3840x2160 -pixel_format nv12 4k_nv12.yuv
使用mpv:
mpv 4k_nv12.yuv --demuxer=rawvideo --demuxer-rawvideo-w=3840 --demuxer-rawvideo-h=2160 \ --demuxer-rawvideo-mp-format=nv12 --demuxer-rawvideo-fps=60
- 查看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:~$ export DISPLAY=:0.0 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:~$ export DISPLAY=:0.0 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