Difference between revisions of "Template:DebianBullseyeDesktop-XFCE-HDMIIN"

From FriendlyELEC WiKi
Jump to: navigation, search
(updated by API)
(updated by API)
Line 57: Line 57:
 
</syntaxhighlight>
 
</syntaxhighlight>
 
* Preview
 
* Preview
 +
use ffplay:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 +
export DISPLAY=:0.0
 
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>
 +
use mpv:
 +
<syntaxhighlight lang="bash">
 +
export DISPLAY=:0.0
 +
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 10:26, 18 June 2023

1 How to test HDMI-IN

1.1 Using V4L2

The node of HDMI-IN device is: /dev/video0, which can be operated by the v4l2-ctl command.

  • Obtain device information
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
  • View the resolution and image format of the currently connected device
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
  • Capture a frame
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
  • Preview

use ffplay:

export DISPLAY=:0.0
ffplay -f rawvideo -video_size 3840x2160 -pixel_format nv12 4k_nv12.yuv

use mpv:

export DISPLAY=:0.0
mpv 4k_nv12.yuv --demuxer=rawvideo --demuxer-rawvideo-w=3840 --demuxer-rawvideo-h=2160 \
    --demuxer-rawvideo-mp-format=nv12 --demuxer-rawvideo-fps=60
  • View HDMI-IN audio device
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

As you can see, the sound card number of HDMI-IN is 4.

  • Recording audio (recording 10 seconds)
pi@NanoPC-T6:~$ arecord -D hw:4,0 -f cd test.wav -d 10
  • Playback recorded audio (output to HDMI0)
pi@NanoPC-T6:~$ aplay test.wav -D 'hw:rockchiphdmi0'

1.2 Using GStreamer

  • Live Preview
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
  • Audio and video recording
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"
  • Live preview + audio and video recording
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