rpi

A faire






compiler mpv avec les filtres

rpi3-01
b8:27:eb:5f:c5:1c
rpi3-02
b8:27:eb:62:64:0e
lenovo01
b4:0e:de:ce:cf:7f


git clone https://github.com/mpv-player/mpv-build.git
pip3 list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip3 install -U


    

Installation de rasperry Pi Os avec Pi Imager



1- utiliser raspberry pi imager pour remplir la carte SD avec le système raspbian
https://www.raspberrypi.org/downloads/

2- booter sa rpi et se loguer
log : pi 
mdp : raspberry

3- configurer sa rpi
ouvrir un terminal ou 
sudo raspi-config
boot autologin

4- installer un programme
sudo apt install omxplayer

Update rpi


sudo rpi-update

Accès à distance en SSH => d'abord s'assurer d'avoir laccès SSH activé, avec:
raspi-config

Accès en réseaux via SSH depuis un terminal
ssh pi@192.168.1.12 (noter l'adresse IP présentée au démarrage du PI)
pass: raspberry

Accès en réseaux via SSH avec gestion de l'interface graphique
ssh -X pi@192.168.1.12 
pass: raspberry

Si Erreur « port 22: Connection refused »
-> vérifier connexion ssh active sur Pi-config
Sinon:
sudo service ssh status (démarré?)
ssh -V (installé?)
sudo apt-get install openssh-server (installation serveur ssh)
sudo service ssh start (lancer serveur ssh)

Erreur lors d'un accès terminal sous OSX:
——————————————————————————————————————————————————————
« WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! »
——————————————————————————————————————————————————————

Solution, autoriser l'ip:
ssh-keygen -R 192.168.1.11 (ip du PI a autoriser)

WIFI

Scan wifi network:
sudo iwlist wlan0 scan 

Configuration WIFI:
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Puis ajouter a la fin:

network={
    ssid="wifiname"
    psk="password"
}

Desactiver wifi:
ifconfig wlan0 down


CONFIGURATION ECRAN 5" TOUCH 800X480


paramètres de BOOT  dans partition boot config.txt


framebuffer_width=800
framebuffer_height=480
hdmi_force_hotplug=1
hdmi_group=2
hdmi_mode=87
hdmi_edid_file=1
hdmi_cvt  800  480  60  6  0  0  0 
dtoverlay=ads7846,penirq=22,speed=100000,xohms=150
dtparam=spi=on

télécharger edid.dat
https://wiki.52pi.com/index.php/EP-0072#Parameters


préparation d'une rpi pour lancement auto d'une vidéo


on suppose que on dispose d'une rpi et d'une carte sd avec raspbian d'installé (parfois déjà fourni dans les kits)

1- configurer console/autologin


ramboise->preferences->raspberry pi config->System->Boot->To CLI (to Command Line Interface)

2- écrire/modifier un script qui se lance à l'autologin


éditer le fichier /home/pi/.bashrc
nano /home/pi/.bashrc
omxplayer --no-osd --loop /home/pi/mavideo.mp4

3- pour sortir et éteindre la rpi (si rpi pas verouillée)


appuyer sur Q (comme quit)
sudo halt

Verouillage / déverouillage d'une rpi


manip permettant de garantir la pérennité de votre install sur rpi malgré coupure de courant, arrachement de carte sd, etc...
(la manip n'est pas instantané car elle requiert la réécriture du fichier initramfs)
!attention: une fois verouillé vous pouvez avoir l'impression de mettre à jour la rpi, installer de nouveaux programmes mais tout se déroule dans la RAM et rien ne sera conservé au prochain reboot...

ouvrir un terminal (

sudo raspi-config

7   -   ADVANCED OPTIONS
A8 -   OVERLAYFS

pour sortir ou appuyer sur finish ->| (touche TAB)

!attention: pour complètement vérouiller, il faut également verouiller le boot (la partition en fat32)

pour déverouiller


même manip mais demander à déverouiller la partition linux (ext4) puis reooter
si le boot est verouillé il faut d'abort le déverouiller puis rebooter

audio / son autonome sur hdmi et sans hdmi !!


plutôt préférer 
omxplayer --adev both
amixer set Master 1


cloner rpi


https://github.com/billw2/rpi-clone
insérer SD Card dans lecteur externe

sudo fdisk /dev/sdX
delete all partitions (d d)
write table (w)

cd rpi-clone
sudo ./rpi-clone /dev/sdX

Test concluant et rapide également depuis l'interface symbolique de raspbian: dans Accessoire -> SD Card Copier

RPI setup static ip address


ip link
sudo nano /etc/dhcpcd.conf
interface eth0
static ip_address=192.168.0.4/24    
static routers=192.168.0.254
static domain_name_servers=192.168.0.254 8.8.8.8


Son vidéo photo


pour les photos attention à la résolution et taille
omxplayer --adev alsa --loop truc.wav
ffmpeg -loop 1 -i 31.jpg -t 1 31.mp4
omxplayer --adev alsa --no-osd --loop /home/pi/Music/criquets.wav &
mpv --loop-playlist --no-audio /home/pi/Videos/playlist


MP4Museum v5: lecture en boucle "sans pause" ou "seamless" avec vlc


https://mp4museum.org/download/
- Pause/stop controlable avec GPIO

MP4Museum-Sync : Synchronisation de plusieurs vidéos avec omxplayer


Image complète Master / Slave 
https://mp4museum.org/download/

-> A faire / utile : intégrer un pilotage manuelle du lecteur avec touches clavier ou gpio
Utiliser dbus pour communiquer à omxplayer-sync (Master) afin que les slave suivent.


Installation manuelle omxplayer-sync (mise à jour 2020)



https://github.com/turingmachine/omxplayer-sync

apt-get install libpcre3 fonts-freefont-ttf fbset libssh-4 python3-dbus
- Pas nécessaire de suivre la procédure installation omxplayer (ancienne) car pb libssl1.0.0 sous buster... nous avons téléchargé la derniere version:

wget -O /usr/bin/omxplayer-sync https://github.com/turingmachine/omxplayer-sync/raw/master/omxplayer-sync
chmod 0755 /usr/bin/omxplayer-sync
wget https://github.com/turingmachine/omxplayer-sync/raw/master/synctest.mp4

- Ajouter cette procédure: http://reillydonovan.com/multichannel-sync-on-raspberry-pi/

pip install pexpect
sudo apt-get install python-dbus

master: omxplayer-sync -luv omxplayer-sync/synctest.mp4 (-> le nom de la vidéo doit être le même)
slave: omxplayer-sync -luv omxplayer-sync/synctest.mp4

- Réglage du script sync (tolérance):
 sudo nano /usr/bin/omxplayer-sync
 
[note] L'utilisation des cables ethernet est beaucoup plus stable que le wifi pour ne pas avoir de re-sync (sinon changer la tolérance dans le script)

Lancer omxplayer / omxplayer-sync au démarrage


sudo nano .bashrc

Ajouter à la fin (le Master à 5sec de delais pour initialisation ok):
    
if [[ "$(tty)" == "/dev/tty1" ]]
 then
     echo "Je suis le master"
     sleep 5; omxplayer-sync -muv omxplayer-sync/synctest.mp4.
fi

options omxplayer
--no-osd --loop /home/pi/

[note]: Pb lors d'un test avec vidéo composite: la synchro se fait trop difficilement car le player lag
"Because composite video requires a very specific clock, setting that clock to the required speed on the Pi 4 means that other clocks connected to it are detrimentally affected, which slightly slows down the entire system."
https://www.raspberrypi.org/documentation/configuration/config-txt/video.md
http://reillydonovan.com/multichannel-sync-on-raspberry-pi/

Lancer au démarrage dans X11 (lxde)


sudo emacs /etc/xdg/lxsession/LXDE-pi/autostart
@chromium-browser --kiosk /home/pi/index.html

ou mieux, déléguer à un script shell
@/home/pi/supersonique/start.sh

dans le script (start.sh chmod a+x start.sh)
cd /home/pi/supersonique
rhizome config.js &
sleep 10
chromium-browser --kiosk http://localhost:8000/supersonique.html

get rid of mouse cursor
sudo apt-get install unclutter
unclutter -idle 0 &

install pulseaudio


sudo apt install pamix pavucontrol pulseaudio pulseaudio-module-zeroconf alsa-utils avahi-daemon

install pocketsphinx


sudo apt-get install -qq python python-dev python-pip build-essential swig git libpulse-dev libasound2-dev
python -m pip install --upgrade pip setuptools wheel
pip install --upgrade pocketsphinx

utiliser pocketsphinx


python
from pocketsphinx import LiveSpeech
for phrase in LiveSpeech(): print( phrase )

changer la rotation de l'écran


1-  sudo nano /boot/config.txt
2 - move all the way down to the end of the file
3 - add the line: display_rotate=1
4 - Press ctrl + o to save and ctrl + x to exit the file
0 = 0 degrees (the default value)
1 = 90 degrees
2 = 180 degrees
3 = 270 degrees
X11
xrandr --output HDMI-1 --rotate left

lancer au démarrage


add in nano .bashrc the commands you wish, like
setfont /usr/share/consolefonts/Uni3-Terminus28x14.psf.gz

attention aux espaces avant et après les crochets

if [[ "$(tty)" == "/dev/tty1" ]]
 then
     echo "ma chouette vidéo au démarrage"
     mpv --shuffle --loop-playlist -fs --rpi-background=yes --no-audio --hwdec=mmal -vo=rpi /home/pi/Videos
fi


X11
sudo apt install gnome-terminal
sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
@ => va chercher le chemin auto
@gnome-terminal --full-screen -e /home/pi/start.py 

configuration lxterminal


emacs ~/.config/lxterminal/lxterminal.conf

omxplayer avec systemd


sudo nano /etc/systemd/user/omxplayer.service

omxplayer-sync -muv omxplayer-sync/synctest.mp4
omxplayer-sync -luv omxplayer-sync/synctest.mp4

[Unit]
Description=omxplayercamview service
After=network.target 

[Service]
Type=simple

User=pi
ExecStart=/usr/bin/omxplayer /home/pi/synctest.mp4

ExecReload=/bin/kill -HUP $MAINPID
KillMode=control-group

# Whether systemd will continue over-watch and restart on any halt
Restart=on-failure
RestartSec=3
[Install]
WantedBy=multi-user.target


sudo systemctl enable omxplayer


todo

Ou placer tous les liens et infos qui doivent etre accessibles aux etudiants ?
compatible sound interface for RPI, audiobox presonus ?

rpi image :
    wifi config

push
broadcast
vidéo
openframeworks

configuration ecran/overscan etc (boot/config.txt)
OMX Player et ofOmxPlayer
Bases du terminal et navigation/edition avec les commandes
SSH ou VNC
Ecran tactile officiel


Download rspbian
https://www.raspberrypi.org/downloads/raspbian/
Installing Raspbian from Win
https://www.raspberrypi.org/documentation/installation/installing-images/windows.md
Update RPI
https://www.raspberrypi.org/documentation/raspbian/updating.md


Day 1 history + videoplayer


jour 1
am
introduction / présentation (pour les nuls)
distribution, connexions
jouer une vidéo
pm
linux, emacs, terminal, compilation
exemples d'openframeworks, compiler

history


Introduction to what is RPI, as an object and it's history and development... Small summary with examples of what we will do and future collaborative projects to think about. Price
RPI official screen : very affordable tablet !
gnu/linux + debian 
système unix, architecture
le terminal
éditeur de texte : emacs
Install raspbian from mac, windows
Initial config : 
Interface and startup // boot scripts // inittab tty
backup sdcard and clone

videoplayer


convert videos through ffmpeg  h264
Launch an HD video with omxPlayer
learn how to autostart  any program after plugging the RPI

Day 2 OF


jour 2
am
installer raspian
au démarrage lancement d'une vidéo en boucle
pm
installation openframeworks
diaporama aléatoire
Install OF
Learn base shell commands and how to navigate
Analysing one or two OF example, modifying them, and showing others
video player with scripts with ofOmxPlayer

Day 3 WALL


jour 3
sensehat
Multiband broadcast to make a giant PiWall
SSH / VNC

Day 4


jour 4
piwall
webcam ps3
opencv
Ableton push
sensehat
Collective work of triggered images and sounds



Synchronization omxplayer-synch


sudo su
apt-get remove omxplayer
rm -rf /usr/bin/omxplayer /usr/bin/omxplayer.bin /usr/lib/omxplayer
wget -O- http://yokto.net/0/omxplayer/omxplayer-3176db4.tar.bz2 | tar -C / -xjvf -
ln -sf /lib/arm-linux-gnueabihf/libpcre.so.3 /lib/arm-linux-gnueabihf/libpcre.so.1
wget -O /usr/bin/omxplayer-sync https://github.com/turingmachine/omxplayer-sync/raw/master/omxplayer-sync
chmod 0755 /usr/bin/omxplayer-sync
apt-get install python-pexpect python-dbus

réencodage :
ffmpeg  -y -i seq1.mp4  -threads 8 -vcodec libx264 -preset veryfast -crf 20 -an seq1_scrub.mp4


master


omxplayer-sync -muv chen.mp4

slave


omxplayer-sync -luv chen.mp4

Raspberry Pi


Pablo Cavero, Vincent Rioux


Les Raspberry Pi, nano-ordinateurs créés il y a 3 ans, et disponibles pour seulement 30 €, se sont répandus à plus de 5 millions d'exemplaires dans le monde. Il s'agit d'un ordinateur au format d'une carte bancaire, équipé de ports standards (USB, HDMI, JACK, etc) et autant capable qu'une simple unité centrale, qui peut par exemple lire et traiter de la vidéo HD.
Les Raspberry sont souvent utilisés pour des installations artistiques visuelles, sonores ou interactives. Leur bas coût, et simplicité d'utilisation, les rendent idéaux pour des dispositifs multimédia en exposition.
Lors de ce workshop, il s'agira d'installer un système sur Raspberry, d'aborder les bases de Linux, ainsi qu'étudier des exemples de programmes ouvrant vers les capacités créatives de ces outils.
Logiciels : Linux, C++, Openframeworks.


OF examples
3dexamples (just to show performance potential)
3dprimitives
advanced3d

events
simple timer

graphics
color
graphicsexample

audio
audiooutputexample
soundplayerexample

video
videoplayerexample

NETWORKING


scp  bin/data/logo.stl pi@10.10.10.143:~

SON



configuration GUI
alsamixer

aplay --list-devices

Volume: Passer le volume alsa à 100% (-de bruit sur le jack):
volume amixer  sset PCM,0 100%

To make the settings permanent do...
amixer controls #and check which numid is ’Master Playback Volume’
amixer cset numid=1 100% #adapt this value
sudo alsactl store

Test son:
speaker-test -r 22050

Tester les channels audio:
aplay /usr/share/sounds/alsa/*
aplay /usr/share/sounds/alsa/Front_Center.wav

avec zoomH4
mplayer -ao alsa:device=hw=1.0 /usr/share/scratch/Media/Sounds/Vocals/Sing-me-a-song.mp3

Gigaport AG = 6sorties
GigaportHD = non détectée
GigaportHD+ = marche?
GigaportEx = test ok 8 channels (mode 7.1)

Pure Data



Installation 
sudo apt-get install puredata

Voir les versions disponibles
apt-cache show puredata -> voir les infos détaillés disponibles
sudo apt-cache policy puredata => affiche les verisons installées ET disponibles de puredata

Libraries / externals
https://deken.puredata.info/

sudo apt-cache search pd-* => chercher toutes les libraries puredata disponibles
sudo apt-cache search "^pd-" => voir toutes les occurrences

sudo apt-get install pd-whatever ->installer une lib (+ add path / lib)
apt list *puredata* -> liste avec détail des paquets

Compiler derniere version pour Raspbian avec Jack:


    
sudo apt install build-essential autoconf automake libtool gettext git libasound2-dev libjack-jackd2-dev libfftw3-3 libfftw3-dev tcl tk
wget http://msp.ucsd.edu/Software/pd-0.50-2.src.tar.gz
tar -xzf pd-0.50-2.src.tar.gz
cd pd-0.50-2
./autogen.sh
./configure --enable-jack --enable-fftw
make

Utiliser AlsaMidi sous Raspbian

lister périphériques midi:
amidi -l

Connecter entrées/sorties
connect Device_Name:Midi_channel Device_Name:Midi_channel
exemples:
aconnect “SQ-1”:0 “Pure Data”:0

Ex: lancer puredata avec un script:
pd -alsamidi -mididev 1 -open /home/pi/patch.pd &
sleep 5
aconnect “SQ-1”:0 “Pure Data”:0

ou pour éviter le sleep:

  while ! aconnect --list | grep "Pure Data"; do sleep 0.1;
-> continu seulement après que puredata apparaisse

Lecture vidéo fluide en mode "scratch" avec FFMPEG:
    
Encodage haute qualité, avec une image clé pour chaque image:
ffmpeg -i input.mp4 -preset slow -crf 18 -vcodec libx264 -x264-params keyint=1 output.mp4

Encodage haute qualité, avec une image clé pour chaque image + découpage temporel + nouvelle résolution:
ffmpeg -ss hh:mm:ss -to hh:mm:ss -i input.mp4 -vf scale=640:480 -preset slow -crf 18 -vcodec libx264 -x264-params keyint=1 output.mp4

Alimentation sur batterie






































# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode
hdmi_safe=1

# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
disable_overscan=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720

# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
hdmi_drive=2
hdmi_force_edid_audio=1

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on

# Uncomment this to enable infrared communication.
#dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
#dtoverlay=vc4-fkms-v3d
max_framebuffers=2

[all]
#dtoverlay=vc4-fkms-v3d
#gpu_mem=256
#enable_tvout=1
#display_rotate=0

[all]
#dtoverlay=vc4-kms-v3d
initramfs initrd.img-5.4.51-v7+-overlay


MPV-BUILD


mpv_options
--enable-rpi
--enable-libmpv-shared

ffmpeg_options
--extra-ldflags=-latomic
--enable-mmal