Archivio mensile 23 April 2018

Katzenjammer del 22-4-2018

Asteroidi persi, batteri che mangiano la plastica, peperoncini, Carla Dellevigne, e monete con i bluetooth. Questo è stato katzenjammer del 22 aprile 2018. 

 

  1. Il cielo su Roma – Colle Der Fomento
  2. Bella come Roma – Viito
  3. Quelli Che Benpensano – Frankie HI-NRG MC
  4. I Love LA – Starcrawler
  5. Photograph – R.E.M. Natalie Merchant
  6. With You Tonight – Summer Moon
  7. We Were Beautiful – Belle & Sebastian
  8. TalkTalk – A Perfect Circle
  9. Communication Breakdown – Led Zeppelin
  10. Pornobisogno – Management Del Dolore Post Operatorio
  11. Better Than That – Edit – James
  12. Disappointing Diamonds Are the Rarest of Them All – Father John Misty
  13. In Chains – Edit – The War On Drugs
  14. The Tracers – Johnny Marr
  15. City Looks Pretty – Courtney Barnett
  16. Last Looks (feat. Sharon Van Etten) – Lee Ranaldo Sharon Van Etten
  17. Mercy Mercy Me – Eddie Vedder The Strokes Josh Homme
  18. Sweet Disposition – The Temper Trap
  19. Grace – Jeff Buckley

Katzenjammer del 15 aprile 2018

Barista alla Tesla, Il nuovo braille, Materia e Antimateria e una sonda dallo spessore di un capello. Ma anche tanta musica e altre notizie dal mondo della scienza e della tecnologia

 

  1. Get High (No, I Don’t) – Maximo Park
  2. This Is The New Shit – Marilyn Manson
  3. Never Enough – Stone Temple Pilots
  4. E tu? – Bud Spencer Blues Explosion
  5. Meds – Placebo Alison Mosshart
  6. Sky Full Of Song – Florence + The Machine
  7. Strange Or Be Forgotten – Temples
  8. Hit – The Sugarcubes
  9. Lick the Pavement – Garbage
  10. Magnificent (She Says) – Elbow
  11. No Surprises – Radiohead
  12. Only You – Yazoo
  13. Keep the Car Running – Arcade Fire
  14. Dark Spring – Beach House
  15. Rise – Alfa 9
  16. Tompkins Square Park – Mumford & Sons
  17. Gravity Sucks – Lebanon Hanover
  18. Apathy – Frankie Cosmos
  19. Cosmo – Nel mezzo della notte
  20. Lieve – Marlene Kuntz

Cenerentolà

Le foto dello spettacolo Cenerentolà, per la regia di Laura Jacobbi. In scena al teatro Agorà dal 10 al 15 aprile 2018.

Foto di Giovanna Onofri.

Registrare con Fedora usando ffpmeg

Sono speaker in una web radio (per vostra info https://www.radiocittaperta.it,ogni lunedì) e quello che sto cercando di ottenere è qualcosa che:

  1. Crea un podcast per ogni trasmissione, data l’ora di inizio e di fine
  2. Consenta allo speaker di avviare e interrompere manualmente una registrazione della trasmissione
  3. Abilita lo speaker a scegliere se sovrascrivere o meno la registrazione automatica
  4. Caricare sul sito web il podcast
  5. Crea la pagina con il podcast

Questi sono compiti abbastanza complicati da svolgere per una singola risorsa IT, ma Roma non è stata costruita in un giorno. Questo post riguarda la registrazione dello streaming audio dalla linea di input della scheda audio collegata, utilizzando una pagina Web per avviare e interrompere la registrazione. Prima di tutto la radio ha due computer con Fedora, sono configurati come gemelli, solo per ridondanza. Nell’installazione di apache ho installato anche un’installazione base di wordpress, questo mi dà le funzionalità di un CMS (accesso utente, password persa, gestione dei plugin) in modo da concentrarmi solo sui requisiti. Ho creato un plugin wordpress con un semplice pulsante frontend: Start --> Stop Il comportamento segue questo percorso https://trac.ffmpeg.org/wiki/PHP :

  • php avvia un record usando ffmpeg in background
  • il pid del processo viene salvato nel database
  • sul lato client (javascript nel browser) una richiesta ajax controlla se il processo è ancora attivo
  • il pulsante di arresto interrompe il processo utilizzando il numero pid (“kill -9 <pid#>”)

Ci sono diversi punti dolenti da tenere in considerazione quando si utilizza questo approccio: ho iniziato con il comando arecord e pipe con la libreria lame per salvare i file mp3, ma sembra che arecord possa essere eseguito solo una volta per risorsa (risorsa = scheda audio) e anche ha un problema che non so perché: si ferma dopo 1h 33m (ref. http://stackoverflow.com/questions/42457839/recording-with-arecord-stops-after-1h-33m-under-fedora-23 ), quindi sono passato a ffmpeg. L’utente Apache non è stato in grado di utilizzare l’audio. Questa è una limitazione sulla maggior parte della distribuzione, ho dovuto aggiungere l’utente apache ai gruppi: audio,pulse,pulse-access e ho aggiunto anche gruppi video (non so se è necessario) comando è: usermod -a -G  video,audio,pulse,pulse-access  apache Un altro punto dolente su Fedora era SELinux. SELinux è un’utility abilitata per impostazione predefinita, per gestire le policy di sicurezza. Esistono diversi modi per aggirare questo problema: indagare e impostare la politica perfetta per le cartelle (molte di esse sono cartelle di memoria condivisa), impostare SELinux in modo che sia più permissivo, disabilitare SELinux. Non voglio dirti la soluzione perfetta, l’ho disabilitata, ma non voglio che tu lo faccia, è una situazione legata alla sicurezza e un ripristino dopo un disastro di sicurezza è qualcosa che davvero non vuoi . La classe wrapper ffmpeg che ho scritto è

<?php

include_once 'Executer.php';

/**
 * Description of FfmpegWrapper
 * * @author mbarsocchi */ class FfmpegWrapper {

    public function startRecord($mountpoint = null, $name, $timeToRun = null) {
        $timeStringToRun = "";
        $filename = $name . ".mp3";
        if ($timeToRun != null) {
            $timeStringToRun = "-t " . $timeToRun;
        } $command = "/usr/bin/ffmpeg -y -f pulse -i alsa_input.usb-Focusrite_Scarlett_Solo_USB-00.analog-stereo -loglevel fatal " . $timeStringToRun . " -c:a libmp3lame -b:a 192k " . dirname(__FILE__) . DIRECTORY_SEPARATOR . "ripped" . DIRECTORY_SEPARATOR . $filename . " </dev/null";
        $exec = new Executer();
        $exec->execute($command, true);
        $res['retcode'] = $exec->getRetCode();
        $res['output'] = $exec->getOutput();
        $res['pid'] = $exec->getPid();
        return $res;
    }

    public function stopRecord($pid) {
        $exec = new Executer();
        $exec->stopPid($pid);
        $res['retcode'] = $exec->getRetCode();
        $res['output'] = $exec->getOutput();
        return $res;
    }

}Executer è una classe di supporto che avvolge il comando shell_exec. Questa classe è anche in grado di ottenere flag background=true o background=false. Quando viene impostato background=true, il pid del processo viene salvato nel DB con alcune informazioni aggiuntive, nel mio caso le informazioni aggiuntive sono il nome dell'mp3 registrato. Per fermare la registrazione, ho usato brutalmente un Kill -9 <pid>. So di poter reindirizzare std-in in un file e usarlo come file-socket per inviare il comando [q] a ffmpeg (ffmpeg è uno strumento interattivo, quindi puoi inviare il comando mentre lavori, q sta per "esci") . Puoi anche scegliere una soluzione più elegante, io uso questa perché non voglio scherzare con i file lasciati... e cose del genere. Nella pagina ajax chiama un endpoint per recuperare il processo in esecuzione, se è presente un processo live, la pagina ha il pulsante STOP con una chiamata asincrona a un endpoint che chiama:

FfmpegWrapper:: stopRecord(<pid>) In caso contrario, il pulsante è START. Questa soluzione funziona molto bene per le mie esigenze e spero che questo post ti aiuti in una soluzione simile.

Record from Fedora via ffpmeg

I’m playing around a web radio (for your info http://www.radiocittaperta.it, I’m also a speaker on Sunday) and what I’m trying to achieve is something that:

  1. Create podcast for every shows, given the start and stop hour
  2. Enable the speaker to manually start and stop a recording of the show
  3. Enable the speaker to choose if overwrite the automatic record or not
  4. Upload to the radio website
  5. Create the page with the podcast

Those are quite complicated task to be done for a single IT resource, but Rome wasn’t built in a day. This post is about recording the audio streaming from the input line of the attached sound card, using a webpage to start-stop the record. First of all the radio has two computer with Fedora, they are configured as twins, just for redundancy. In the apache installation I have also installed a wordpress base installation, this gives me the functionalities of a CMS (user access, lost password, plugin management) in order to focus only on the requirments. I have created a wordpress plugin with a simple frontend button:  

Start --> Stop

  The behaviour follow this path https://trac.ffmpeg.org/wiki/PHP :

  • php start a record using ffmpeg in background
  • the pid of the process is saved in the database
  • on client side (javascript in the browser) an ajax request check if the process is still alive
  • stop button kills process using pid number (“kill -9 <pid#>”)

There are several pain points to take into account when using this approach: I started with arecord command, and pipe with lame library to save mp3 files, but seems that arecord could run only once per-resource (resource=sound card) and it also has a problem that I don’t know why: it’s stops after 1h 33m (ref. http://stackoverflow.com/questions/42457839/recording-with-arecord-stops-after-1h-33m-under-fedora-23) , so I switched to ffmpeg. Apache user could not been able to use audio. This is a limitation on most of the distro, I had to add apache user to the groups:

audio,pulse,pulse-access and I’ve added also video groups (don’t know if it’s necessary)

command is:

usermod -a -G  video,audio,pulse,pulse-access  apache

Another pain point on Fedora was SELinux. SELinux is an utility enabled by default, to manage security policy. There are several ways to work around this: investigate and set the perfect policy for folders (a lot of them are shared-memory folders), set the SELinux to be more permissive, disable SELinux. I don’t want to tell you the perfect solution, I’ve disabled it, but I don’t want you to do so, it’s a security related situation and a recovery after a security disaster is something that you really don’t want. The ffmpeg wrapper class I wrote is 

<?php

include_once 'Executer.php';

/**
 * Description of FfmpegWrapper
 * * @author mbarsocchi */ class FfmpegWrapper {

    public function startRecord($mountpoint = null, $name, $timeToRun = null) {
        $timeStringToRun = "";
        $filename = $name . ".mp3";
        if ($timeToRun != null) {
            $timeStringToRun = "-t " . $timeToRun;
        } $command = "/usr/bin/ffmpeg -y -f pulse -i alsa_input.usb-Focusrite_Scarlett_Solo_USB-00.analog-stereo -loglevel fatal " . $timeStringToRun . " -c:a libmp3lame -b:a 192k " . dirname(__FILE__) . DIRECTORY_SEPARATOR . "ripped" . DIRECTORY_SEPARATOR . $filename . " </dev/null";
        $exec = new Executer();
        $exec->execute($command, true);
        $res['retcode'] = $exec->getRetCode();
        $res['output'] = $exec->getOutput();
        $res['pid'] = $exec->getPid();
        return $res;
    }

    public function stopRecord($pid) {
        $exec = new Executer();
        $exec->stopPid($pid);
        $res['retcode'] = $exec->getRetCode();
        $res['output'] = $exec->getOutput();
        return $res;
    }

}

Executer is a support class that wraps the shell_exec command. This class is also capable of getting background=true or background=false flag. When background=true is setted, the pid of the process is saved into DB with some additional information, in my case the additional infos are the name of the mp3 recorded. To stop the recording, I’ve used a brutally Kill -9 <pid>. I know I can redirect std-in in a file and use it as a file-socket to send the [q] command to ffmpeg (ffmpeg is an interactive tool, so you can send command while working, q is for “quit”). You can also choose a more elegant solution, I use this because I don’t want to mess around with left files… and stuff like this.  On the page ajax call an endpoint to retrieve the runnig process, if there is a live process, the page has the button STOP with a async call to an endpoint that calls:

FfmpegWrapper:: stopRecord(<pid>)

If not, the button is START. This solution works very well for my needs, and hope this post helps you in similar solution. 

Scaletta e podcast del 9 aprile 2018

Sex toys e i super-afrodisiaci che vengono dal mare, 2001 odissea nello spazio, Lucertolone con 4 occhi. Materia oscura.

  1. The Times – Barbott
  2. Can’t Deny Me – Pearl Jam
  3. Bad Days Are Back – Giuda
  4. Rocks – Primal Scream George Drakoulias David Bianco
  5. Autonomic – DBFC
  6. Permanating – Steven Wilson
  7. Over the Midnight – Jonathan Wilson
  8. I Don’t Want To Get Down – Wrongonyou
  9. Nuit de mes rêves – Scratch Massive
  10. La nostra ultima canzone – Motta
  11. Man in the Box – Alice In Chains
  12. Zero – The Smashing Pumpkins
  13. Per Non Riprendersi – Germanò
  14. Nu poco ‘e bene – Gnut
  15. Premonition – Eels
  16. El Gatopardo – Triángulo de Amor Bizarro
  17. Aftermath – Rolo Tomassi
  18. Lithium – Nirvana
  19. What Else Is There ? – Röyksopp

Pasquetta 2018

Cosa è stato più bello di questa pasquetta? L’oziare? La compagnia amichevole? L’ospitalità ospitale della padrona di casa Margherita o il suo compleanno? Il sole senza pioggia o, più verosimilmente, la presenza del sommo Bosho? chi lo sa…chi lo sa…