- koseungjin
- Posts: 4
- Joined: Thu Aug 28, 2025 8:50 am
why raspberrypi 4 + kmssink slow?
"Why does Raspberry Pi 4 + v4l2 + kmssink take so long to load, about 5 seconds? Has anyone solved this issue?"
- 6by9
- Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator - Posts: 18476
- Joined: Wed Dec 04, 2013 11:27 am
Re: why raspberrypi 4 + kmssink slow?
I suspect that it's just the normal GStreamer format negotiation that takes a few moments - it all looks to be in going from PAUSED to PREROLLING.
What format are you using from V4L2? Complete pipeline command please. Is GStreamer having to insert format conversions?
What format are you using from V4L2? Complete pipeline command please. Is GStreamer having to insert format conversions?
Software Engineer at Raspberry Pi Ltd. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.
I'm not interested in doing contracts for bespoke functionality - please don't ask.
- koseungjin
- Posts: 4
- Joined: Thu Aug 28, 2025 8:50 am
Re: why raspberrypi 4 + kmssink slow?
GST_DEBUG="kmssink:7" gst-launch-1.0 videotestsrc ! kmssink
Setting pipeline to PAUSED ...
0:00:03.096814035 41772 0x55b1b52460 INFO kmssink gstkmssink.c:671:log_drm_version:<kmssink0> DRM v0.0.0 [vc4 — Broadcom VC4 graphics — 0]
0:00:03.096943220 41772 0x55b1b52460 INFO kmssink gstkmssink.c:716:get_drm_caps:<kmssink0> prime import (✓) / prime export (✓) / async page flip (✓)
0:00:03.251720403 41772 0x55b1b52460 INFO kmssink gstkmssink.c:849:ensure_allowed_ca
itis about 3~ 5seconds then start view on camera
Setting pipeline to PAUSED ...
0:00:03.096814035 41772 0x55b1b52460 INFO kmssink gstkmssink.c:671:log_drm_version:<kmssink0> DRM v0.0.0 [vc4 — Broadcom VC4 graphics — 0]
0:00:03.096943220 41772 0x55b1b52460 INFO kmssink gstkmssink.c:716:get_drm_caps:<kmssink0> prime import (✓) / prime export (✓) / async page flip (✓)
0:00:03.251720403 41772 0x55b1b52460 INFO kmssink gstkmssink.c:849:ensure_allowed_ca
itis about 3~ 5seconds then start view on camera
- 6by9
- Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator - Posts: 18476
- Joined: Wed Dec 04, 2013 11:27 am
Re: why raspberrypi 4 + kmssink slow?
I've only just had a chance to look further.
kmssink goes and tries opening /dev/dri/card0 all the way up to /dev/dri/card63, poking each one 50 times with a 20usec delay between each attempt, and then does that multiple times.
Using "strace gst-launch-1.0 videotestsrc ! kmssink 2> log.txt" and then "less log.txt | grep "AT_FDCWD, ./dev/dri/card" | wc -l" lists 39638 different attempts to open a directory a /dev/dri/cardN, and each also appears to check for /dev/dri existing first.
That would appear to be libdrm at https://gitlab.freedesktop.org/mesa/lib ... heads#L892
50 attempts with a 20usec delay between attempts for each.
Gstreamer is calling drmOpen with a sequence of driver names at https://gitlab.freedesktop.org/gstreame ... heads#L478
So we've got 13 other driver name attempts before we try "vc4", each one generating 50 retries for each of 62 directories that don't exist (card0 and card1 will), each with a 20usec delay. 13 * 50 * 62 = 40300 attempts.
Specify the DRM driver to use with
it avoids all that searching, and starting almost immediately.
kmssink goes and tries opening /dev/dri/card0 all the way up to /dev/dri/card63, poking each one 50 times with a 20usec delay between each attempt, and then does that multiple times.
Using "strace gst-launch-1.0 videotestsrc ! kmssink 2> log.txt" and then "less log.txt | grep "AT_FDCWD, ./dev/dri/card" | wc -l" lists 39638 different attempts to open a directory a /dev/dri/cardN, and each also appears to check for /dev/dri existing first.
That would appear to be libdrm at https://gitlab.freedesktop.org/mesa/lib ... heads#L892
50 attempts with a 20usec delay between attempts for each.
Gstreamer is calling drmOpen with a sequence of driver names at https://gitlab.freedesktop.org/gstreame ... heads#L478
So we've got 13 other driver name attempts before we try "vc4", each one generating 50 retries for each of 62 directories that don't exist (card0 and card1 will), each with a 20usec delay. 13 * 50 * 62 = 40300 attempts.
Specify the DRM driver to use with
Code: Select all
gst-launch-1.0 videotestsrc ! kmssink driver-name=vc4Software Engineer at Raspberry Pi Ltd. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.
I'm not interested in doing contracts for bespoke functionality - please don't ask.
- koseungjin
- Posts: 4
- Joined: Thu Aug 28, 2025 8:50 am
Re: why raspberrypi 4 + kmssink slow?
thank you so much you are the best
:)
:)
Jump to
- Community
- General discussion
- Announcements
- Other languages
- Deutsch
- Español
- Français
- Italiano
- Nederlands
- 日本語
- Polski
- Português
- Русский
- Türkçe
- User groups and events
- Raspberry Pi Official Magazine
- Using the Raspberry Pi
- Beginners
- Troubleshooting
- Advanced users
- Assistive technology and accessibility
- Education
- Picademy
- Teaching and learning resources
- Staffroom, classroom and projects
- Astro Pi
- Mathematica
- High Altitude Balloon
- Weather station
- Programming
- C/C++
- Java
- Python
- Scratch
- Other programming languages
- Windows 10 for IoT
- Wolfram Language
- Bare metal, Assembly language
- Graphics programming
- OpenGLES
- OpenVG
- OpenMAX
- General programming discussion
- Projects
- Networking and servers
- Automation, sensing and robotics
- Graphics, sound and multimedia
- Other projects
- Media centres
- Gaming
- AIY Projects
- Hardware and peripherals
- Camera board
- Compute Module
- Official Display
- HATs and other add-ons
- Device Tree
- Interfacing (DSI, CSI, I2C, etc.)
- Keyboard computers (400, 500, 500+)
- Raspberry Pi Pico
- General
- SDK
- MicroPython
- Other RP2040 boards
- Zephyr
- Rust
- AI Accelerator
- AI Camera - IMX500
- Hailo
- Software
- Raspberry Pi OS
- Raspberry Pi Connect
- Raspberry Pi Desktop for PC and Mac
- Beta testing
- Other
- Android
- Debian
- FreeBSD
- Gentoo
- Linux Kernel
- NetBSD
- openSUSE
- Plan 9
- Puppy
- Arch
- Pidora / Fedora
- RISCOS
- Ubuntu
- Ye Olde Pi Shoppe
- For sale
- Wanted
- Off topic
- Off topic discussion