Which system do you use? Android, Ubuntu, OOWOW or others?
Ubuntu server
Which version of system do you use? Please provide the version of the system here:
Ubuntu 24.04 LTS Linux 5.15.119
Please describe your issue below:
The hdmi-in gstreamer example only works if started from a logged in tty.
It fails if I start it from rc.local or systemd - producing empty video.
exec gst-launch-1.0 \
v4l2src device=/dev/video71 io-mode=dmabuf \
! video/x-raw,width=1920,height=1080,framerate=30/1,format=NV12 \
! amlvenc gop=0 bitrate=5000 ! video/x-h264,profile=high \
! h264parse ! rtph264pay config-interval=1 mtu=1208 \
! "application/x-rtp, payload=(int)96, ssrc=(uint)555555" \
! udpsink host=127.0.0.1 port=${1}
Post a console log of your issue below:
No log or error messages I have seen.
numbqq
September 18, 2024, 12:59am
2
Hello @steely-glint
@ivan.li will help you later.
1 Like
ivan.li
September 23, 2024, 1:08am
4
@steely-glint
Can you provide detailed steps?
@ivan.li hi, Sure, here are my steps…
I plugged the HDMI out of a VIM4 into the hdmiin on the same device
logged in over ssh and ran the example.
(VIM4 HDMI Input for 5.15 Kernel [Khadas Docs] )
It works.
But I can’t autostart it.
I created a file
khadas@WeightOfTheWheel:~$ cat testhdmi.sh
#!/bin/sh
nohup gst-launch-1.0 v4l2src device=/dev/video71 io-mode=dmabuf num-buffers=300 ! video/x-raw,format=NV12,width=1920,height=1080,framerate=30/1,interlace-mode=interleaved ! amlvenc ! h264parse ! qtmux ! filesink location=/tmp/test71.mp4 > /tmp/gst.log &
and added this to the end of /etc/rc.local:
su - khadas -c "/home/khadas/testhdmi.sh"
When I power cycle the gstreamer never completes.
PID TTY STAT TIME COMMAND
1130 ? Ss 0:00 /usr/lib/systemd/systemd --user
1131 ? S 0:00 (sd-pam)
1144 ? Sl 0:00 gst-launch-1.0 v4l2src device=/dev/video71 io-mode=
1161 ? Sl 0:00 hdmictrl
1216 tty1 S+ 0:00 -bash
1269 ? S 0:01 sshd: khadas@pts/0
1270 pts/0 Ss 0:00 -bash
1329 pts/0 R+ 0:00 ps -x
The log file contains:
khadas@WeightOfTheWheel:~$ cat /tmp/gst.log
Setting pipeline to PAUSED ...
khadas 1158 0.0 0.0 2380 816 ? S 15:30 0:00 sh -c -- ps -aux | grep hdmictrl
khadas 1160 0.0 0.0 6140 2004 ? S 15:30 0:00 grep hdmictrl
unix 2 [ ACC ] STREAM LISTENING 23090 /tmp/hdmi-rx0
unix 3 [ ] STREAM CONNECTED 23091 /tmp/hdmi-rx0
khadas@WeightOfTheWheel:~$
I think it wants a controlling terminal or something - wrapping it in screen(1) doesn’t help though.
Can you help please?
Thanks.
Tim
ivan.li
September 27, 2024, 1:26am
6
Hello @steely-glint
Please use systemd service to manage script startup.
systemd service file example:
[Unit]
Description=testhdmi.sh
After=network.target
[Service]
User=khadas
ExecStart=/home/khadas/testhdmi.sh
Restart=on-failure
RestartSec=30
[Install]
WantedBy=multi-user.target
systemctl enable testhdmi.service
systemctl start testhdmi.service
systemctl status testhdmi.service
I tweaked the script to remove the nohup and the & so it now looks like this:
khadas@WeightOfTheWheel:~$ cat testhdmi.sh
#!/bin/sh
rm -f /tmp/test71.mp4
rm -f /tmp/gst.log
gst-launch-1.0 v4l2src device=/dev/video71 io-mode=dmabuf num-buffers=300 ! video/x-raw,format=NV12,width=1920,height=1080,framerate=30/1,interlace-mode=interleaved ! amlvenc ! h264parse ! qtmux ! filesink location=/tmp/test71.mp4 > /tmp/gst.log 2>&1
And added your systemd service file to /etc/systemd/system/testhdmi.service
Same result. The gstreamer never outputs a frame and remains PAUSED.
khadas@WeightOfTheWheel:~$ cat /tmp/gst.log
Setting pipeline to PAUSED ...
[2024-09-27 09:42:14] DEBUG [amlv4l2src hdmisrc.c:102:hdmi_src_initialize]enter
khadas 1632 0.0 0.0 2380 816 ? S 09:42 0:00 sh -c -- ps -aux | grep hdmictrl
khadas 1634 0.0 0.0 6140 2008 ? S 09:42 0:00 grep hdmictrl
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmisrc.c:68:hdmi_src_obtain_devname]enter
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmisrc.c:79:hdmi_src_obtain_devname]hdmi_src_obtain_devname, pid=1635
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmisrc.c:87:hdmi_src_obtain_devname]hdmi_src_obtain_devname end, pid=1635
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmisrc.c:79:hdmi_src_obtain_devname]hdmi_src_obtain_devname, pid=0
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmisrc.c:83:hdmi_src_obtain_devname]ready to execl /usr/bin/hdmictrl, pid=0
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmictrl.c:304:main]enter, prepare enter hdmi_rx_svctx_init
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmictrl.c:256:hdmi_rx_svctx_init]enter
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmictrl.c:264:hdmi_rx_svctx_init]prepare get the GetInstance
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmictrl.c:271:hdmi_rx_svctx_init]go hdmi_rx_svctx_perform_connect
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmictrl.c:202:hdmi_rx_svctx_perform_connect]enter
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmictrl.c:229:hdmi_rx_svctx_perform_connect][64285336]UNIX domain socket (/tmp/hdmi-rx0) bound
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmictrl.c:238:hdmi_rx_svctx_perform_connect][64309252]Accepting connections,get the client_unix_len: 110
[2024-09-27 09:42:15] DEBUG [amlv4l2src common/common.c:70:udp_sock_create][64304044][/tmp/hdmi-rx0] start connect
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmisrc.c:97:hdmi_src_obtain_devname]exit
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmisrc.c:109:hdmi_src_initialize]send_buffer:fd:9 buf:connect
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmisrc.c:112:hdmi_src_initialize]exit
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmisrc.c:138:hdmi_src_start]enter
unix 2 [ ACC ] STREAM LISTENING 33869 /tmp/hdmi-rx0
unix 3 [ ] STREAM CONNECTED 33870 /tmp/hdmi-rx0
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmictrl.c:248:hdmi_rx_svctx_perform_connect]g_t_svctx prepare get the connect_socker_fd 10
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmictrl.c:251:hdmi_rx_svctx_perform_connect]exit
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmictrl.c:278:hdmi_rx_svctx_init]exit
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmictrl.c:311:main]prepare enter setTvEventCallback
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmictrl.c:314:main]prepare enter process_socket_thread
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmictrl.c:139:process_socket_thread]enter
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmictrl.c:144:process_socket_thread]hdmirxsrc is (null)
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmictrl.c:148:process_socket_thread]HDMISRC is hdmi1
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmictrl.c:165:process_socket_thread]e_currentsource = 5
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmictrl.c:169:process_socket_thread]loop wait recv cmd
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmictrl.c:171:process_socket_thread]recv_buffer = connect
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmictrl.c:172:process_socket_thread]r = 32 errno = 0
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmictrl.c:183:process_socket_thread]Enter connect_hdmi
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmictrl.c:186:process_socket_thread]Exit connect_hdmi
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmictrl.c:189:process_socket_thread]startv is ok
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmictrl.c:169:process_socket_thread]loop wait recv cmd
[2024-09-27 09:42:15] DEBUG [amlv4l2src hdmictrl.c:117:TvEventCallback]source: 5, signalFmt: 0, transFmt: 0, status: 1, isDVI: 0, Hdrinfo: 65792d
khadas@WeightOfTheWheel:~$ ls -l /tmp/test71.mp4
-rw-r--r-- 1 khadas khadas 0 Sep 27 09:42 /tmp/test71.mp4
If I run the gstreamer by hand in a ssh session it works.
Thanks.
Tim.
ivan.li
September 29, 2024, 3:50am
8
Hello @steely-glint
This issue is being analyzed and will be updated here later.
Hi @ivan.li , yes, HDMI is connected to a 1080p (non hdcp) device.
The script works when run by hand from a ssh connection or on the console, but does not work when started from systemd or rc.local .