Hardware accelerated video playback on the Raspberry Pi...in 3 moves
Posted: 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
Edit the file
And replace the QLCPLUS_OPTS line to look like this
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
And add the following before the 'exit 0' line
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:
or this
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:
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:
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.
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
Code: Select all
/etc/init.d/qlcplus
Code: Select all
QLCPLUS_OPTS="-platform linuxfb --web --operate --nogui"
- 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
Code: Select all
setterm -cursor off
clear > /dev/tty1
setterm -blank 1
setterm -blank force
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"
Code: Select all
systemcommand:/usr/bin/omxplayer arg:"/opt/Sintel.2010.720p.mkv"
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
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"
I just wanted to 'early' share this to understand your opinions if this is a valuable functionality or not.