Plugin: smooth video playback on Raspberry Pi

521 views
Skip to first unread message

YFL

unread,
Sep 5, 2016, 3:41:18 PM9/5/16
to MPF Users
Hi,

I started experimenting with video backgrounds in my slides and realized the performance is really bad to unusable on the Raspi3. 
Seems like Kivy does not make good use of the hardware decoding while on the other hand, `omxplayer` plays HD videos at 60 fps without any problems.

So I came up with this super dirty but effective hack. Basically I made the Kivy window transparent and start a video player, which shows up below my MPF slides. 
Then I use an MPF event and a python scriptlet to control the video player. It sounds horrible but works quite well in practice.

Demo video:
https://youtu.be/0eL0hHpMdWM

Source:

Feedback welcome! 

Have fun :)

Cheers
YFL

jabdoa

unread,
Sep 5, 2016, 3:59:38 PM9/5/16
to MPF Users
Hi YFL,

looks cool. Nice hack!

I wounder why Kivy is so slow in your case. 1. Is that running on the framebuffer or using a display manager? 2. Did you install gst-omx/gstreamer-omx package? In that case Kivy should also use omxplayer.


Jan

YFL

unread,
Sep 5, 2016, 5:03:22 PM9/5/16
to MPF Users
Hi jabdoa,

nice hint, sounds like a much cleaner solution! It would be amazing to have hardware support directly from Kivy.

What I have now is no window manager, just the framebuffer.

On `mpf mc` startup I get:

INFO : kivy : VideoGstplayer: Using Gstreamer 1.4.4.0
INFO : kivy : Video: Provider: gstplayer

I think the Gstreamer version I have is not the good one for the Raspi.

So probably I'll have to remove this version, install v0.10 (which seems not trivial at all from what I've seen from a quick google search) and recompile Kivy.

Will try at some point.

jabdoa

unread,
Sep 5, 2016, 5:23:38 PM9/5/16
to MPF Users
You can also try kivypie. Its a debian for Rpi3 where all the dirty stuff is already done: http://docs.missionpinball.org/en/stable/install/raspberry.html


Jan

YFL

unread,
Sep 5, 2016, 7:41:14 PM9/5/16
to MPF Users
Hi jabdoa,

I just tried the kivypie an here's my findings: 

It boots really fast and I'll keep it!

The kivy-providers and the output of gst-inspect-1.0 are the same as with my other setup.

However video performance has slightly improved. If I include a video through kivy, it _almost_ plays smoothly, however CPU load jumps up to > 90 %.

As before, playing the same video through `hello_video` does not increase the CPU load at all and it plays without any stutter.

Maybe the kivy-way of handling videos just has too much overhead for the little Raspi.

Best,
YFL

Jan Kantert

unread,
Sep 5, 2016, 7:43:14 PM9/5/16
to mpf-...@googlegroups.com
Thanks for sharing!


Jan

jabdoa

unread,
Sep 9, 2016, 5:12:34 AM9/9/16
to MPF Users
Hi YFL,

can you try "python3 -m kivy.uix.videoplayer your video.mpf" and see if that also shows high CPU usage? In that case it would be a Kivy problem and hard for us to fix (maybe we could investigate gst-omx). If it works we can probably change MPF to play the video in the same way.


Jan

YFL

unread,
Sep 13, 2016, 6:44:05 PM9/13/16
to MPF Users
Hi jabdoa,

thanks for following this up. I tried your suggestion and can confirm seeing the same kind of high CPU usage (> 95 % on one core) with kivy.uix.videoplayer. The same video plays with negligible CPU usage with hello_video or omxplayer.

Tested on Kivy Pie Version: 0.9b

Best, YFL
Reply all
Reply to author
Forward
0 new messages