dimanche 20 décembre 2020

Build mpd (Music Player Daemon) on a Raspberry Pi



apt install meson g++ libpcre3-dev libmad0-dev libmpg123-dev libid3tag0-dev libflac-dev libvorbis-dev libopus-dev libogg-dev libadplug-dev libaudiofile-dev libsndfile1-dev libfaad-dev libfluidsynth-dev libgme-dev libmikmod-dev libmodplug-dev libmpcdec-dev libwavpack-dev libwildmidi-dev libsidplay2-dev libsidutils-dev libresid-builder-dev libavcodec-dev libavformat-dev libmp3lame-dev libtwolame-dev libshine-dev libsamplerate0-dev libsoxr-dev libbz2-dev libcdio-paranoia-dev libiso9660-dev libmms-dev libzzip-dev libcurl4-gnutls-dev libyajl-dev libexpat-dev libasound2-dev libao-dev libjack-jackd2-dev libopenal-dev libpulse-dev libshout3-dev libsndio-dev libmpdclient-dev libnfs-dev libupnp-dev libavahi-client-dev libsqlite3-dev libsystemd-dev libgtest-dev libboost-dev libicu-dev libchromaprint-dev libgcrypt20-dev

git pull --rebase git://github.com/MusicPlayerDaemon/MPD master
cd MPD
git pull --rebase git://github.com/MusicPlayerDaemon/MPD master
meson . output/release --buildtype=debugoptimized -Db_ndebug=true
meson configure output/release
ninja -C output/release
sudo ninja -C output/release install


mercredi 16 décembre 2020

Un peu de ffmpeg

Créer une vidéo avec une liste d'images/photos :

Sous Linux:

cat *.jpg | ffmpeg -f image2pipe -r 1 -vcodec mjpeg -i - -vcodec libx264 out.mp4

 

Sous Windows:

ffmpeg -r 1/5 -i gmic_pencilbw_000000_000%03d.png -c:v libx264 -vf fps=25 -pix_fmt yuv420p out.mp4


Créer l'image du spectre audio d'un fichier audio ou vidéo:

ffmpeg -y -i tets.mp3 -lavfi showspectrumpic=s=1200x600:fscale=log:color=rainbow spectrum.png
 
 

Encodage NVIDIA:

ffmpeg -i "e:\input.ts" -vcodec h264_nvenc -preset slow -level 4.1 -qmin 18 -qmax 22 "e:\output.mp4"

Ou bien :

ffmpeg -loglevel debug -threads 4 -hwaccel cuvid -c:v mpeg2_cuvid -i "e:\input.ts" \
-filter:v scale_npp=w=1920:h=1080:format=yuv420p:interp_algo=lanczos \
-c:v h264_nvenc -preset:v llhq -profile:v main -level:v 4.1 -rc:v ll_2pass_quality -rc-lookahead:v 32 -temporal-aq:v 1 -weighted_pred:v 1 -coder:v cabac \
-f mp4 "e:\output.mp4" 
 

lundi 7 décembre 2020

Windows 10 : Utilisation simultané d'une connexion Ethernet pour le LAN et d'une connexion 4G ou autre pour le WAN

 Suite à une panne de box, j'ai eu recours à mon téléphone portable pour utiliser Internet.

J'ai autorisé le partage par USB sur mon téléphone, connecté celui-ci au PC, mais ça ne fonctionné pas car ma connexion Ethernet été toujours active, si je désactivais cette connexion Ethernet, l'accès à Internet était possible mais alors plus d'accès au réseau local (NAS, etc... )

La solution trouvé ici (et ailleurs) : connexion simultanée wifi et ethernet win10 (pcastuces.com)

Panneau de config -> Centre Réseau et partage -> sur la gauche Modifier les param de carte

  1. Clic droit sur la carte a faire passer en priorité haute (Ethernet) -> Propriétés
  2. Sélectionnez Protocole Internet version 4 -> propriétés
  3. Bouton « Avancé… » tout en bas
  4. Décochez ensuite Métrique automatique et entrez une métrique de l’interface a 1
  5. Répétez ces étapes pour l'interfaces 4G (ou freewifi) mettant 2 en métrique sachant que plus la métrique est haute moins la carte est prioritaire

Par exemple: Connexion 4G en "10" et connexion Ethernet en "20"

Maintenant il est possible accéder au deux réseaux !


mardi 22 septembre 2020

 MPD et les streams Radio France

J'utilise MPD sur un raspberry conjointement avec l'interface web mympd.
J'écoute principalement des streams de Radio France en haute qualité (AAC 192 kbs) et depuis quelques semaines et le matin seulement je constate des coupures du son voir l'abandon par MPD du stream qui passe au suivant de la playlist.

J'ai corrigé ce problème en remplacent le plugin d'entrée curl par ffmpeg
J'ai modifier le plugin d'entrée:
input {
        plugin "ffmpeg"
}
 
#input {
#        plugin "curl"
#}
... et ça ne résou rien :(
 
J'ai regardé les paquets TCP échangés. 
J'ai remarqué que le dns renvoyé plusieurs adresses IP pour le serveur radiofrance:
Première essai de connexion: 
Domain Name System (response)
Transaction ID: 0xbeed
Flags: 0x8180 Standard query response, No error
Questions: 1
Answer RRs: 7
Authority RRs: 0
Additional RRs: 0
Queries
Answers
icecast.radiofrance.fr: type CNAME, class IN, cname icecasta.prods1public.radiofrance.fr
icecasta.prods1public.radiofrance.fr: type A, class IN, addr 163.172.182.190
icecasta.prods1public.radiofrance.fr: type A, class IN, addr 51.158.65.164
icecasta.prods1public.radiofrance.fr: type A, class IN, addr 212.47.251.152
icecasta.prods1public.radiofrance.fr: type A, class IN, addr 51.158.117.244
icecasta.prods1public.radiofrance.fr: type A, class IN, addr 51.158.104.58
icecasta.prods1public.radiofrance.fr: type A, class IN, addr 163.172.145.72
[Request In: 1]
[Time: 0.027922000 seconds]

le player utilise la dernière proposée:
-> icecasta.prods1public.radiofrance.fr: type A, class IN, addr 163.172.145.72

Deuxième essai de connexion:
Domain Name System (response)
Transaction ID: 0x101d
Flags: 0x8180 Standard query response, No error
Questions: 1
Answer RRs: 7
Authority RRs: 0
Additional RRs: 0
Queries
Answers
icecast.radiofrance.fr: type CNAME, class IN, cname icecasta.prods1public.radiofrance.fr
icecasta.prods1public.radiofrance.fr: type A, class IN, addr 163.172.182.190
icecasta.prods1public.radiofrance.fr: type A, class IN, addr 51.158.117.244
icecasta.prods1public.radiofrance.fr: type A, class IN, addr 51.158.104.58
icecasta.prods1public.radiofrance.fr: type A, class IN, addr 163.172.145.72
icecasta.prods1public.radiofrance.fr: type A, class IN, addr 51.158.65.164
icecasta.prods1public.radiofrance.fr: type A, class IN, addr 212.47.251.152
[Request In: 1]
[Time: 0.026924000 seconds]


le player utilise la dernière proposée:
 -> icecasta.prods1public.radiofrance.fr: type A, class IN, addr 212.47.251.152 
 
Je pense que le player web du site radiofrance "jongle" avec ces adresses pour utiliser le serveur le plus disponible au lieu de prendre le dernier..
Un coup d'oeil sur les paquets échangés lors de l'utilisation du player web, montre des échanges bien plus complexes.
Le player fini par utiliser 2.21.132.169 comme serveur de stream, soit : a2-21-132-169.deploy.static.akamaitechnologies.com  ...
 

 


 

jeudi 10 septembre 2020

Music Player Daemon build on Raspberry Pi

Build MPD from sources on Raspberry Pi 

Original post here:

Get the sources:

git clone https://github.com/MusicPlayerDaemon/MPD.git 
cd MPD 

Get all necessary dependencies

sudo apt-get install g++ \
  libpcre3-dev \
  libmad0-dev libmpg123-dev libid3tag0-dev \
  libflac-dev libvorbis-dev libopus-dev \
  libadplug-dev libaudiofile-dev libsndfile1-dev libfaad-dev \
  libfluidsynth-dev libgme-dev libmikmod2-dev libmodplug-dev \
  libmpcdec-dev libwavpack-dev libwildmidi-dev \
  libsidplay2-dev libsidutils-dev libresid-builder-dev \
  libavcodec-dev libavformat-dev \
  libmp3lame-dev libtwolame-dev libshine-dev \
  libsamplerate0-dev libsoxr-dev \
  libbz2-dev libcdio-paranoia-dev libiso9660-dev libmms-dev \
  libzzip-dev \
  libcurl4-gnutls-dev libyajl-dev libexpat-dev \
  libasound2-dev libao-dev libjack-jackd2-dev libopenal-dev \
  libpulse-dev libshout3-dev \
  libsndio-dev \
  libmpdclient-dev \
  libnfs-dev libsmbclient-dev \
  libupnp-dev \
  libavahi-client-dev \
  libsqlite3-dev \
  libsystemd-dev libwrap0-dev \
  libgtest-dev \
  libboost-dev \
  libicu-dev \
  libgcrypt-dev \
  libsidplayfp-dev

Install messon and ninja tools:

sudo apt-get install python3 python3-pip ninja-build
sudo pip3 install meson 

Stop mpd service:

sudo service mpd stop 

Compile mpd:

meson . output/release --buildtype=debugoptimized -Db_ndebug=true
meson configure output/release
ninja -C output/release
sudo ninja -C output/release install  
  • mpd is in ./output/release
  • service files are ./output/release/systemd
  • use the mpdconf.example in ./doc for configuration

Workarrounds and errors:

mpd binary is located in /usr/local/bin and this mpd binary try to open mpd.conf located in /usr/local/etc NOT in usual folder /etc

So, you have to link these file and folder:

sudo mv /usr/bin/mpd /usr/bin/mpd_old
sudo ln -s /usr/local/bin/mpd /usr/bin/mpd

Check if folder /usr/local/etc already exists:

ls /usr/local

If an etc folder exists, rename it to etc_bak

sudo mv /usr/local/etc /usr/local/etc_old

Link etc folder:

sudo ln -s /etc /usr/local

move old etc files to linked folder:

sudo mv /usr/local/etc_old/* /usr/local/etc

dimanche 12 janvier 2020

Repairing Domoticz database...

Some error appearing in domoticz log concerning VACUUM:

2020-01-12 15:00:01.363 Error: SQL Query("VACUUM") : database disk image is malformed

First, stop domoticz:

$ sudo service domoticz.sh stop

Backup the database:

$ cp ./domoticz/domoticz.db ./domoticz/domoticz.db.bak

Method 1

$ sqlite3 ./domoticz/domoticz.db
sqlite> .output domo.sql 
sqlite> .dump
sqlite> .quit

Download domo.sql to your Windows PC,

Try to import domo.sql in Sqlite Browser ( https://sqlitebrowser.org/ ) ,
Note error messages if exists and cleanup manualy ( notepad++ ) domo.sql (duplicate inserts, etc...) until importation success.

When sql is successfully imported, save to "domoticz.db"
Upload to domoticz machine, 

$ rm ./domoticz/domoticz.db
$ cp ./domoticz.db ./domoticz/domoticz.db
$ sudo service domoticz.sh start

If no success then :
$ rm ./domoticz/domoticz.db
$ cp ./domoticz/domoticz.db.bak ./domoticz/domoticz.db

Method 2 (not worked for me)

Open database with sqlite3:

$ sqlite3 ./domoticz/domoticz.db

Check integrity:

sqlite> PRAGMA integrity_check;
*** in database main ***
On tree page 138 cell 50: Rowid 2287 out of order
row 252 missing from index ds_hduts_idx
wrong # of entries in index ds_hduts_idx
...

First reindex DeviceStatus:

sqlite> reindex ds_hduts_idx;

Check integrity again:

sqlite> PRAGMA integrity_check;
*** in database main ***
On tree page 138 cell 50: Rowid 2287 out of order

... Error: database disk image is malformed

Build a clean copy of database:

sqlite> .clone domoticz-clone.sqlite

DeviceStatus... done
LightingLog... done
SceneLog... done
Preferences... done
Rain... done
Rain_Calendar... done
Temperature... done
Temperature_Calendar... done
Timers... done
SetpointTimers... done
UV... done
UV_Calendar... done
Wind... done
Wind_Calendar... done
Meter... done
Meter_Calendar... done
MultiMeter... done
MultiMeter_Calendar... done
Notifications... done
Hardware... done
Users... done
LightSubDevices... done
Cameras... done
CamerasActiveDevices... done
DeviceToPlansMap... done
Plans... done
Scenes... done
SceneDevices... done
TimerPlans... done
SceneTimers... done
SharedDevices... done
EventMaster... done
EventRules... done
ZWaveNodes... done
WOLNodes... done
Percentage... done
Percentage_Calendar... done
Fan... done
Fan_Calendar... done
BackupLog... done
EnoceanSensors... done
FibaroLink... done
HttpLink... done
PushLink... done
GooglePubSubLink... done
UserVariables... done
Floorplans... done
CustomImages... done
MySensors... done
MySensorsVars... done
MySensorsChilds... done
ToonDevices... done
UserSessions... done
MobileDevices... done
sqlite_stat1... Error: object name reserved for internal use: sqlite_stat1
SQL: [CREATE TABLE sqlite_stat1(tbl,idx,stat)]
Error 1: no such table: sqlite_stat1 on [SELECT * FROM "sqlite_stat1"]
done
sqlite_autoindex_UserSessions_1... done
sqlite_autoindex_UserSessions_2... done
ds_hduts_idx... done
f_id_idx... done
f_id_date_idx... done
fc_id_idx... done
fc_id_date_idx... done
ll_id_idx... done
ll_id_date_idx... done
sl_id_idx... done
sl_id_date_idx... done
m_id_idx... done
m_id_date_idx... done
mc_id_idx... done
mc_id_date_idx... done
mm_id_idx... done
mm_id_date_idx... done
mmc_id_idx... done
mmc_id_date_idx... done
p_id_idx... done
p_id_date_idx... done
pc_id_idx... done
pc_id_date_idx... done
r_id_idx... done
r_id_date_idx... done
rc_id_idx... done
rc_id_date_idx... done
t_id_idx... done
t_id_date_idx... done
tc_id_idx... done
tc_id_date_idx... done
u_id_idx... done
u_id_date_idx... done
uv_id_idx... done
uv_id_date_idx... done
w_id_idx... done
w_id_date_idx... done
wc_id_idx... done
wc_id_date_idx... done
devicestatusupdate... done
deviceplantatusupdate... done
planordertrigger... done
scenesupdate... done
scenedevicesupdate... done
floorplanordertrigger... done
...
sqlite> PRAGMA user_version;
0  <----- TAKE NOTE OF THIS VALUE it may be different for you
sqlite> .exit

Open the database copy and correct:

$ sqlite3 domoticz-clone.sqlite
sqlite> PRAGMA integrity_check;
ok
sqlite> PRAGMA user_version = 0;  -- use the number you got from PRAGMA user_version; above
sqlite> PRAGMA journal_mode = truncate;
truncate
sqlite> PRAGMA page_size = 32768;
sqlite> VACUUM;
sqlite> PRAGMA journal_mode = wal;
wal
sqlite> .exit

Copy new cleaned database on domoticz database:

$ mv domoticz-clone.sqlite ./domoticz/domoticz.db

Finally start domoticz service:

$ sudo service domoticz.sh start

You can now check domoticz log with web ui...