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: 1898
Joined: Sun Apr 12, 2015 9:09 am
Location: Italy
Real Name: Massimo Callegari
Contact:

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

Post by mcallegari » Sun Oct 11, 2015 3:49 pm

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: 3
Joined: Sun Sep 04, 2016 1:46 pm
Real Name: Remco Wiegel

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

Post by dreamview » Sun Sep 04, 2016 1:48 pm

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: 1898
Joined: Sun Apr 12, 2015 9:09 am
Location: Italy
Real Name: Massimo Callegari
Contact:

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

Post by mcallegari » Wed Sep 07, 2016 12:39 pm

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: 16
Joined: Sat Jan 21, 2017 2:07 pm
Real Name: Dave Crewe

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

Post by magicaltrevor70 » Mon Apr 10, 2017 9:03 pm

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?

Post Reply