XBMC: Difference between revisions

5,569 bytes added ,  3 years ago
m (Protected "XBMC" ([Edit=Allow only logged in users] (indefinite) [Move=Allow only logged in users] (indefinite) [Delete=Allow only logged in users] (indefinite)))
 
(31 intermediate revisions by the same user not shown)
Line 1:
[[Category:FunRaspberrypi]]
__TOC__
<br />
Line 69:
|-
|Zoom In, Zoom Out || style="text-align:center;" | + plus, – minus || Picture View
|-
|Toggle Watched || style="text-align:center;" colspan="2" | W
|}
</center>
 
* Video Information Shortcuts:
O
Ctrl + Shift + O
 
 
<br />
 
= OpenELEC Dual Boot=
= OpenELEC Dual Boot on PC=
 
How to dual boot(actually Triple boot) OpenELEC with Ubuntu and Windows.
Line 114 ⟶ 122:
 
<br />
 
 
= LibreElec Shutdown Button =
 
[[File:Pi shutdown switch.png|thumb|right]]
 
Source: [https://forum.libreelec.tv/thread/1754-problem-installing-pi-tools-addon/ libreelec.tv], [https://lowpowerlab.com/forum/atxraspi/libreelec-python-script/ lowpowerlab.com], [https://wiki.libreelec.tv/config.txt libreelec.tv]
 
*Install Raspberry Pi Tools from libreELEC UI:
Program ---> Get more ... ---> Raspberry Pi Tools ---> install
 
* Create shutdown script:
nano /storage/.config/shutdown_pi.py
 
<syntaxhighlight lang="python">
#!/bin/python
import RPi.GPIO as GPIO
import time
import os
import sys
 
sys.path.append("/storage/.kodi/addons/virtual.rpi-tools/lib")
 
# Use the Broadcom SOC Pin numbers
# Setup the Pin with Internal pullups enabled and PIN in reading mode.
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(3, GPIO.IN, pull_up_down = GPIO.PUD_UP)
 
# Our function on what to do when the button is pressed
def Shutdown(channel):
os.system("poweroff")
 
# Add our function to execute when the button pressed event happens
GPIO.add_event_detect(3, GPIO.FALLING, callback = Shutdown, bouncetime = 2000)
 
# Now wait!
while 1:
time.sleep(1)
</syntaxhighlight>
 
* Create Autostart Script:
nano /storage/.config/autostart.sh
 
<syntaxhighlight lang="bash">
#!/bin/bash
(
/storage/.config/shutdown_pi.py
)&
</syntaxhighlight>
 
* Make files executable
chmod +x shutdown_pi.py
chmod +x autostart.sh
 
* Enable UART for the Status LED:
mount -o remount,rw /flash
nano /flash/config.txt
enable_uart=1
 
* Reboot
<br>
 
= OSMC =
 
== OSMC Shutdown Button ==
 
Source: [https://discourse.osmc.tv/t/rpi-gpio-for-led-push-button-relay-module/19070 discourse.osmc.tv]
 
[[File:Pi shutdown switch.png|thumb|right]]
 
*Install Raspberry Pi Tools from CLI:
sudo apt update
sudo apt install python3-pip python3-dev gcc python3-setuptools
sudo pip3 install wheel
sudo pip3 install rpi.gpio
 
* Create shutdown script:
nano /home/osmc/.config/shutdown_pi.py
 
<syntaxhighlight lang="python">
#!/usr/bin/python3
import RPi.GPIO as GPIO
import time
import os
import sys
 
sys.path.append("/storage/.kodi/addons/virtual.rpi-tools/lib")
 
# Use the Broadcom SOC Pin numbers
# Setup the Pin with Internal pullups enabled and PIN in reading mode.
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(3, GPIO.IN, pull_up_down = GPIO.PUD_UP)
 
# Our function on what to do when the button is pressed
def Shutdown(channel):
os.system("poweroff")
 
# Add our function to execute when the button pressed event happens
GPIO.add_event_detect(3, GPIO.FALLING, callback = Shutdown, bouncetime = 2000)
 
# Now wait!
while 1:
time.sleep(1)
</syntaxhighlight>
 
 
* Make files executable
sudo chmod +x shutdown_pi.py
 
*Test Script:
./home/osmc/.config/shutdown_pi.py
 
* Auto Start as a Service
 
Create systemd service file:
sudo nano /lib/systemd/system/shutdownpi.service
 
<pre>
[Unit]
Description = GPIO shutdown button
 
[Service]
Type = idle
ExecStart = /home/osmc/.config/shutdown_pi.py
 
[Install]
WantedBy = multi-user.target
</pre>
 
Enable the service:
sudo systemctl enable shutdownpi
 
Start the service:
sudo systemctl start shutdownpi
 
 
* Enable UART for the Status LED:
sudo nano /boot/config.txt
enable_uart=1
 
* Reboot
<br>
 
== Netflix Addon ==
 
*Install Netflix Addon in Kodi:
https://troypoint.com/netflix-kodi/
 
*If you get Cryptodome.Random missing Error [https://github.com/CastagnaIT/plugin.video.netflix/issues/669]:
pip install pycryptodome
 
*If you get Incorrect Password error [https://github.com/CastagnaIT/plugin.video.netflix/wiki/Login-with-Authentication-key]:
pip3 install pycryptodomex
pip3 install websocket-client
 
Download the NFAuthenticationKey.py file:
https://www.dropbox.com/sh/ls3veptflvneub1/AABz9Tt3EqKUb90PQXNarNxga?dl=0
 
Run the script and follow the instructions:
python3 NFAuthenticationKey.py
 
SCP the file into Kodi's home dir and enter the PIN & Password.
 
= Patch for MPEG2 & VC1 Codecs =
Source: [https://www.reddit.com/r/raspberry_pi/comments/8sg0a6/patch_for_mpeg2_vc1_license_again_for_osmc/#bottom-comments reddit.com]
 
== Verify patching ==
 
*Convert Binary to Hex & grep the file contents:
xxd -u start_x.elf > /tmp/start_x.elf.hex
grep '47 *E9 *33 *36 *32 *48' /tmp/start_x.elf.hex
00b9db0: 47E9 4341 4C46 2118 47E9 3336 3248 1D18 G.CALF!.G.362H..
 
== Method 1 ==
 
*Backup files:
cp /boot/start_x.elf /boot/start_x.elf_backup
cp /boot/start_x.elf ~/start_x.elf
cd ~
cp start_x.elf start_x.elf_backup
 
*Convert \x1D\x18 -> \x1D\x1F:
perl -pne 's/\x47\xE9362H\x1D\x18/\x47\xE9362H\x1D\x1F/g' < start_x.elf_backup > start_x.elf
diff start_x.elf start_x.elf_backup # This should show binaries are different
 
*Replace the binary:
mv ~/start_x.elf /boot/start_x.elf
reboot
 
== Method 2 ==
 
*Create script:
nano patch_codec.sh
 
<syntaxhighlight lang="bash">
#!/bin/bash
function do_patch() {
if [ -f "/boot/${1}" ]; then
cp "/boot/${1}" "/boot/${1}_backup"
perl -pne 's/\x47\xE9362H\x'${2}'\x18/\x47\xE9362H\x'${2}'\x1F/g' < "/boot/${1}_backup" > "/boot/${1}"
echo "Patched /boot/${1}..."
fi
}
do_patch start.elf 3C
do_patch start_x.elf 1D
</syntaxhighlight>
 
*Execute it:
sudo chmod +x patch_codec.sh
sudo ./patch_codec.sh
sudo reboot
 
== Check Codecs ==
for codec in H264 MPG2 WVC1 MPG4 MJPG WMV9; do echo -e "$codec:\t$(vcgencmd codec_enabled $codec)"; done
<br>