Hardware accelerated video playback on the Raspberry Pi...in 3 moves

A place where updates of QLC+ activities and technical articles are posted as if it was a blog
Post Reply
User avatar
mcallegari
Posts: 4446
Joined: Sun Apr 12, 2015 9:09 am
Location: Italy
Real Name: Massimo Callegari
Contact:

First of all, let me say this is kind of a workaround.
Secondly, this is possible with QLC+ 4.10.0 and higher.

As you might know, QLC+ is almost entirely based on the Qt libraries. On the desktop versions, where possible, Qt5 is used, and it takes care of the audio/video playback, through the QtMultimedia library.
The Qt5 version that I build specifically for the Raspberry Pi, includes QtMultimedia too, but unfortunately it works pretty badly. That's why I've never talked about videos on the RPi, and believe me, I tried hard for months to make them work like I wanted.
Apparently the Qt team is not focused on embedded devices, so buddies like the RPi have been left behind.
Let's hope in the future this situation will improve, so QLC+ will be able to use "native" video playback like on the desktop versions.

Today I wanna talk how this situation can be workarounded. The main actor making it possible is omxplayer
omxplayer has been written by the same team that coded Kodi, a fantastic open source cross platform media center that works flawlessy even on the Raspberry Pi.

On the Pi, installing omxplayer requires a very limited footprint (around 25MB), so let's see how you can win this game in 3 moves !

1. White pawn in E4 - QLC+ and friends

Install omxplayer

Code: Select all

apt-get update
apt-get install omxplayer
Edit the file

Code: Select all

/etc/init.d/qlcplus
And replace the QLCPLUS_OPTS line to look like this

Code: Select all

QLCPLUS_OPTS="-platform linuxfb --web --operate --nogui"
The most techy of you, might have noticed that we've done 2 things here:
- hid the QLC+ UI. As we're going to use the HDMI output to play videos, we don't need QLC+ to show up
- told QLC+ to render on the Linux framebuffer. Normally QLC+ on the RPi renders the UI on a OpenGL surface, but since it is needed by omxplayer (and since we don't care about the QLC+ UI), we'll leave it free to be used.

2. Black pawn in F5 - Going black

Now we have the unwanted login message on the screen.
So edit the file

Code: Select all

/etc/rc.local
And add the following before the 'exit 0' line

Code: Select all

setterm -cursor off
clear > /dev/tty1
setterm -blank 1
setterm -blank force
This basically clears the screen and tell the screen console to go blank

3. Queen in H5 - Checkmate: As easy as a Script

Create an empty QLC+ project on your PC.
Add a new Script function, with a line like this to play a video:

Code: Select all

systemcommand:/usr/bin/omxplayer arg:"http://192.168.0.100/Sintel.2010.720p.mkv"
or this

Code: Select all

systemcommand:/usr/bin/omxplayer arg:"/opt/Sintel.2010.720p.mkv"
Create a Virtual Console button and attach your Script to it.
Save.
Load the just created project into your Raspberry Pi via web interface.
Click on the Virtual Console button and you'll have fullscreen, hardware accelerated video playback with your Pi !
Please note that the QLC+ Script will launch omxplayer as a separate process, so the VC button will disengage almost immediately.
To give a duration to the Script, just add a second line to it like this:

Code: Select all

wait:03m14s.00
Piece of cake, right ?

Now you can continue with all the adjustments:
- place your videos into the RPi SD card (remember to expand the filesystem if files are big !)
- set your project to autostart and autostart a Chaser (to automatically loop through a number of videos)
- change the screen resolution. Depending on if you have a HDMI TV set or a HDMI projector you might want to tune the output resolution. This can be done via config.txt file, in the SD card FAT partition. See 'hdmi_mode' here for more info
- change the video size with omxplayer. See the --win option in this page or just type 'omxplayer -h'
You might end up with a Script command like this:

Code: Select all

systemcommand:/usr/bin/omxplayer arg:--win arg:100,100,800,600 arg:"/opt/Sintel.2010.720p.mkv"
QLC+ 4.10.0 should be released during October 2015.
I just wanted to 'early' share this to understand your opinions if this is a valuable functionality or not.
dreamview
Posts: 5
Joined: Sun Sep 04, 2016 1:46 pm
Real Name: Remco Wiegel

This works like a charm, but is there also a way stop the playback once it started? couldn't find any solutions for this... I need to start and stop video playback from QLC+ on a Pi for a project.
User avatar
mcallegari
Posts: 4446
Joined: Sun Apr 12, 2015 9:09 am
Location: Italy
Real Name: Massimo Callegari
Contact:

Well, this post describes just a way of doing video playback with Script functions.

Instead of invoking directly omxplayer, you can write a little bash script with 2 command line args: url and command.
Example:

Code: Select all

hw_video_play.sh /home/pi/myvideo.mp4 START
hw_video_play.sh /home/pi/myvideo.mp4 STOP
The stop command will just retrieve the omxplayer PID and kill it. Not sure if there is a way to stop the video gracefully.
Anyway, just another idea...
magicaltrevor70
Posts: 22
Joined: Sat Jan 21, 2017 2:07 pm
Real Name: Dave Crewe

Hi,

Just tried this, but the options to blank the screen don't seem to work.

I get 'terminal xterm does not support --blank' when entering 'setterm --blank 1'

From a little reading it looks like this might be a bug in Raspian...is there another way of blanking the screen?
yaducam
Posts: 2
Joined: Mon Apr 18, 2022 4:56 am
Real Name: yaducam

I have an issue.
I downloaded the raspberry Pi QLC+ image (i didn't compile from source).

I run it on a RPB3B
I use it with customizable looper pedal (Boss RC-500) to control via midi messages the light & video

However, i have this issue :

No matter what i do, The GUI still appears on HDMI port at startup and take the whole screen
I have tried QLCPLUS_OPTS set : "-platform linuxfb --web --operate --nogui"
or with the nowm option : "-platform linuxfb --web --operate --nogui --nowm"
This doesnt help.

This is a problem because between the omxplayer video transition, QLC+ GUI appears and ruins it all !
It seems quite a lot of people also reported that the nogui option does nothing.

Is the nogui option still supported in the latest QLC+ rasp image or is it deprecated ?
chriscore
Posts: 1
Joined: Thu Feb 01, 2024 6:07 pm
Real Name: Chris Core

yaducam wrote: Mon Apr 18, 2022 5:10 am I have an issue.
I downloaded the raspberry Pi QLC+ image (i didn't compile from source).

I run it on a RPB3B
I use it with customizable looper pedal (Boss RC-500) to control via midi messages the light & video

However, i have this issue :

No matter what i do, The GUI still appears on HDMI port at startup and take the whole screen
I have tried QLCPLUS_OPTS set : "-platform linuxfb --web --operate --nogui"
or with the nowm option : "-platform linuxfb --web --operate --nogui --nowm"
This doesnt help.

This is a problem because between the omxplayer video transition, QLC+ GUI appears and ruins it all !
It seems quite a lot of people also reported that the nogui option does nothing.

Is the nogui option still supported in the latest QLC+ rasp image or is it deprecated ?
I have been trying to use QLC+ on a RPI4 to trigger playback of video by MIDI. So far I've got it all working pretty well, using the suggestions above on RaspiOS Buster (to avoid non-compatibility with omxplayer) but am having the same problem as you: I cannot find a way to get QLC+ to run without the GUI popping up on the HDMI output between each video, which is obviously not going to fly.
I've tried setting the --nogui flag in qlcplus init.d file, though this seems to be simply getting ignored.
I managed to run qlcplus headlessly, using xvfb via the command line (xvfb-run qlcplus -w -p --open "/home/somefile.qxw"), and was considering attempting to modify the qlcplus init.d file to do this, but frustratingly for some reason, when I start QLC+ this way although the web interface starts and QLC seems to run ok, invoking the script via the button remotely doesnt seem to be launching the omxplayer process (nothing happening viewing in htop).

Has anybody got advice please, to suggest how we can run QLC+ on pi without the UI being displayed? Thanks
Last edited by chriscore on Thu Feb 01, 2024 6:28 pm, edited 1 time in total.
Post Reply