Archive for ‘Raspberry Pi’ Category
Browse:
Raspberry Pi »
Subcategories:
  • Assuming you want the fancy splash screen (ie you want to hide the ugly boot messages), add “quiet splash logo.nologo plymouth.ignore-serial-consoles” to the end of the single line in /boot/cmdline.txt file. This enables the splash screen. Now you need to choose one (I like spinfinity), so issue the following command to switch from default (bland grey screen):
    sudo plymouth-set-default-theme spinfinity
  • There are other themes as well (some don’t seem to work properly for me. To find out what’s installed and use it in the above command issue:
    sudo plymouth-set-default-theme -l
  • You might notice that there is a black border on your splash screen. Overscan problem, so disable it by adding (uncommenting) this line to /boot/cmdline.txt
    disable_overscan=1
  • To disable console from blanking out add “consoleblank=0” to the end of the single line in /boot/cmdline.txt file.
  • Might want to get rid of the Linux login prompt on the console (tty1) altogether. Do this only if you’ve got a auto starting script or CLI autologin enabled. The login prompt WILL be disabled.
    sudo systemctl disable getty@tty1.service

So here are the design goals:

  • Provide atleast 6 channels of streaming video.
  • Allow “hot” switching between streams using a remote control.
  • Allow network to fail and be able to have the stream automatically recover.
  • Allow the Pi to autostart on a particular stream when powered.
  • Be flexible enough to potentially provide more than 6 channels of streaming video.
  • System will be hosted on a read-only Micro-SD card to lessen the chance of long term SD corruption.

Here are the assumptions:

  • System is based on Raspberry Pi 2 B+ as a minimum (old Pi 1 and Pi zero have not been tested, but should work).
  • System uses HDMI audio and or analogue audio out from Pi’s 3.5mm jack.
  • System is limited to 720p and 1080p output.
  • System has been tested with video streams up to 6Mb/s.
  • System works with rtmp streaming protocol. Tested with Wowza Streaming server providing 6 streams.

Requirements:

  • Pi 2 B+ or better.
  • Latest raspbian jessie or better.
  • HDMI monitor and cable for testing.
  • Good Pi power supply 5V@2A.
  • speaker or headphone for monitoring during testing phase.
  • 8 GB Micro-SD card.
  • USB keyboard and Mouse (for the building phase only).
  • Ethernet cable.
  • A simple remote control with number pad.
  • A Flirc IR receiver. There are other ways of getting IR into Pi, but this is by far the easiest.

Here we go……

  • So write the raspbian image file to sd.
  • Hook up everything and do your first boot.
  • Pi will boot up and resize the filesystem automatically and reboot. Then you’ll end up in X-windows.
  • Open up terminal and run “sudo raspi-config” command.
  • Change the hostname to something. I chose “signage” for mine.
  • Enable SSH (option 5/P2), enable CLI boot (option 3/B1/B1), change memory split to 128Mb (option 7/A3), change password (option 1) and anything you need under localization options.

Take the reboot at the end of this process. Once back you should have the signage login screen with “Welcome to PIXEL” graphic on the screen. Lets continue……

  • Since my workstation is on the same network as the Pi I can do the following, if you’re not, you can always login (remember the password) using keyboard and issue the command “sudo ifconfig” to find the IP address of your Pi.
  • Use “ssh pi@signage.local” to login to the Pi from your workstation (on windows you need a program like putty to facilitate ssh connections).
  • sudo to root and follow along
  • Update and upgrade to latest greatest
    pi@signage:~ $ sudo -i
    root@signage:~# apt-get update ; apt-get dist-upgrade 
    Get:1 http://mirrordirector.raspbian.org jessie InRelease [14.9 kB]
    Get:2 http://mirrordirector.raspbian.org jessie/main armhf Packages [8,981 kB]
    Get:3 http://archive.raspberrypi.org jessie InRelease [22.9 kB]            
    Get:4 http://archive.raspberrypi.org jessie/main armhf Packages [145 kB]   
    Get:5 http://archive.raspberrypi.org jessie/ui armhf Packages [57.9 kB]                                           
    Ign http://archive.raspberrypi.org jessie/main Translation-en_US                                                                                     
    Ign http://archive.raspberrypi.org jessie/main Translation-en                                                                                        
    Ign http://archive.raspberrypi.org jessie/ui Translation-en_US                                                                                       
    Ign http://archive.raspberrypi.org jessie/ui Translation-en                                                                                          
    Get:6 http://mirrordirector.raspbian.org jessie/contrib armhf Packages [37.5 kB]                                                                     
    Get:7 http://mirrordirector.raspbian.org jessie/non-free armhf Packages [70.3 kB]                                                                    
    Get:8 http://mirrordirector.raspbian.org jessie/rpi armhf Packages [1,356 B]                                                                         
    Ign http://mirrordirector.raspbian.org jessie/contrib Translation-en_US                                                                              
    Ign http://mirrordirector.raspbian.org jessie/contrib Translation-en                                                                                 
    Ign http://mirrordirector.raspbian.org jessie/main Translation-en_US                                                                                 
    Ign http://mirrordirector.raspbian.org jessie/main Translation-en                                                                                    
    Ign http://mirrordirector.raspbian.org jessie/non-free Translation-en_US                                                                             
    Ign http://mirrordirector.raspbian.org jessie/non-free Translation-en                                                                                
    Ign http://mirrordirector.raspbian.org jessie/rpi Translation-en_US                                                                                  
    Ign http://mirrordirector.raspbian.org jessie/rpi Translation-en                                                                                     
    Fetched 9,330 kB in 50s (185 kB/s)                                                                                                                   
    Reading package lists... Done
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    Calculating upgrade... Done
    The following packages will be upgraded:
      alacarte gstreamer1.0-alsa gstreamer1.0-plugins-bad gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-x libaudiofile1
      libgstreamer-plugins-bad1.0-0 libgstreamer-plugins-base1.0-0 libgstreamer1.0-0 libopenblas-base libpam-chksshpwd libpam-modules libpam-modules-bin
      libpam-runtime libpam0g libsmbclient libwbclient0 pi-greeter piclone pix-plym-splash raspberrypi-sys-mods raspberrypi-ui-mods raspi-config
      realvnc-vnc-server rpi-chromium-mods samba-common samba-libs wiringpi wolfram-engine
    30 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    Need to get 274 MB of archives.
    After this operation, 1,623 kB disk space will be freed.
    Do you want to continue? [Y/n] y
    Get:1 http://archive.raspberrypi.org/debian/ jessie/main libpam0g armhf 1.1.8-3.1+deb8u2+rpi3 [121 kB]
    Get:2 http://mirrordirector.raspbian.org/raspbian/ jessie/main libgstreamer1.0-0 armhf 1.4.4-2+deb8u1 [1,593 kB]
    Get:3 http://mirrordirector.raspbian.org/raspbian/ jessie/main libaudiofile1 armhf 0.3.6-2+deb8u2 [97.1 kB]
    Get:4 http://archive.raspberrypi.org/debian/ jessie/main libpam-modules-bin armhf 1.1.8-3.1+deb8u2+rpi3 [101 kB] 
    Get:5 http://archive.raspberrypi.org/debian/ jessie/main libpam-modules armhf 1.1.8-3.1+deb8u2+rpi3 [288 kB]
    Get:6 http://mirrordirector.raspbian.org/raspbian/ jessie/main libgstreamer-plugins-base1.0-0 armhf 1.4.4-2+deb8u1 [1,248 kB]
    Get:7 http://mirrordirector.raspbian.org/raspbian/ jessie/main libwbclient0 armhf 2:4.2.14+dfsg-0+deb8u4 [118 kB]
    Get:8 http://archive.raspberrypi.org/debian/ jessie/main wolfram-engine armhf 11.0.1+2017031701 [240 MB]           
    Get:9 http://mirrordirector.raspbian.org/raspbian/ jessie/main libsmbclient armhf 2:4.2.14+dfsg-0+deb8u4 [139 kB]
    Get:10 http://mirrordirector.raspbian.org/raspbian/ jessie/main samba-libs armhf 2:4.2.14+dfsg-0+deb8u4 [4,246 kB]
    Get:11 http://mirrordirector.raspbian.org/raspbian/ jessie/main gstreamer1.0-plugins-good armhf 1.4.4-2+deb8u3 [2,218 kB]
    Get:12 http://mirrordirector.raspbian.org/raspbian/ jessie/main gstreamer1.0-plugins-bad armhf 1.4.4-2.1+deb8u2 [2,231 kB]     
    Get:13 http://mirrordirector.raspbian.org/raspbian/ jessie/main gstreamer1.0-plugins-base armhf 1.4.4-2+deb8u1 [1,236 kB]                            
    Get:14 http://mirrordirector.raspbian.org/raspbian/ jessie/main samba-common all 2:4.2.14+dfsg-0+deb8u4 [243 kB]                                     
    Get:15 http://mirrordirector.raspbian.org/raspbian/ jessie/main libgstreamer-plugins-bad1.0-0 armhf 1.4.4-2.1+deb8u2 [1,299 kB]                      
    Get:16 http://mirrordirector.raspbian.org/raspbian/ jessie/main gstreamer1.0-alsa armhf 1.4.4-2+deb8u1 [790 kB]                                      
    Get:17 http://mirrordirector.raspbian.org/raspbian/ jessie/main gstreamer1.0-x armhf 1.4.4-2+deb8u1 [823 kB]                                         
    Get:18 http://archive.raspberrypi.org/debian/ jessie/main libpam-runtime all 1.1.8-3.1+deb8u2+rpi3 [213 kB]                                          
    Get:19 http://archive.raspberrypi.org/debian/ jessie/ui alacarte all 3.11.91-2+rpi4 [111 kB]                                                         
    Get:20 http://archive.raspberrypi.org/debian/ jessie/main libopenblas-base armhf 0.2.12-1+rpi1 [1,688 kB]                                            
    Get:21 http://archive.raspberrypi.org/debian/ jessie/main libpam-chksshpwd armhf 1.1.8-3.1+deb8u2+rpi3 [79.3 kB]                                     
    Get:22 http://archive.raspberrypi.org/debian/ jessie/ui pi-greeter armhf 0.4 [41.3 kB]                                                               
    Get:23 http://archive.raspberrypi.org/debian/ jessie/ui piclone armhf 0.4 [13.2 kB]                                                                  
    Get:24 http://archive.raspberrypi.org/debian/ jessie/ui pix-plym-splash armhf 0.9 [25.4 kB]                                                          
    Get:25 http://archive.raspberrypi.org/debian/ jessie/main raspberrypi-sys-mods all 20170313 [8,596 B]                                                
    Get:26 http://archive.raspberrypi.org/debian/ jessie/main realvnc-vnc-server armhf 6.0.2.26558 [5,305 kB]                                            
    Get:27 http://archive.raspberrypi.org/debian/ jessie/ui rpi-chromium-mods armhf 20170317 [9,185 kB]                                                  
    Get:28 http://archive.raspberrypi.org/debian/ jessie/main wiringpi armhf 2.44 [52.7 kB]                                                              
    Get:29 http://archive.raspberrypi.org/debian/ jessie/ui raspberrypi-ui-mods all 1.20170315 [426 kB]                                                  
    Get:30 http://archive.raspberrypi.org/debian/ jessie/main raspi-config all 20170307 [18.7 kB]                                                        
    Fetched 274 MB in 22min 41s (201 kB/s)                                                                                                               
    Reading changelogs... Done
    Preconfiguring packages ...
    (Reading database ... 112361 files and directories currently installed.)
    Preparing to unpack .../libpam0g_1.1.8-3.1+deb8u2+rpi3_armhf.deb ...
    Unpacking libpam0g:armhf (1.1.8-3.1+deb8u2+rpi3) over (1.1.8-3.1+deb8u2+rpi1) ...
    Processing triggers for libc-bin (2.19-18+deb8u7) ...
    Setting up libpam0g:armhf (1.1.8-3.1+deb8u2+rpi3) ...
    Processing triggers for libc-bin (2.19-18+deb8u7) ...
    (Reading database ... 112361 files and directories currently installed.)
    Preparing to unpack .../libpam-modules-bin_1.1.8-3.1+deb8u2+rpi3_armhf.deb ...
    Unpacking libpam-modules-bin (1.1.8-3.1+deb8u2+rpi3) over (1.1.8-3.1+deb8u2+rpi1) ...
    Processing triggers for man-db (2.7.0.2-5) ...
    Setting up libpam-modules-bin (1.1.8-3.1+deb8u2+rpi3) ...
    (Reading database ... 112361 files and directories currently installed.)
    Preparing to unpack .../libpam-modules_1.1.8-3.1+deb8u2+rpi3_armhf.deb ...
    Unpacking libpam-modules:armhf (1.1.8-3.1+deb8u2+rpi3) over (1.1.8-3.1+deb8u2+rpi1) ...
    Processing triggers for man-db (2.7.0.2-5) ...
    Setting up libpam-modules:armhf (1.1.8-3.1+deb8u2+rpi3) ...
    (Reading database ... 112361 files and directories currently installed.)
    Preparing to unpack .../libaudiofile1_0.3.6-2+deb8u2_armhf.deb ...
    Unpacking libaudiofile1:armhf (0.3.6-2+deb8u2) over (0.3.6-2+deb8u1) ...
    Preparing to unpack .../libgstreamer1.0-0_1.4.4-2+deb8u1_armhf.deb ...
    Unpacking libgstreamer1.0-0:armhf (1.4.4-2+deb8u1) over (1.4.4-2) ...
    Preparing to unpack .../libgstreamer-plugins-base1.0-0_1.4.4-2+deb8u1_armhf.deb ...
    Unpacking libgstreamer-plugins-base1.0-0:armhf (1.4.4-2+deb8u1) over (1.4.4-2) ...
    Preparing to unpack .../libwbclient0_2%3a4.2.14+dfsg-0+deb8u4_armhf.deb ...
    Unpacking libwbclient0:armhf (2:4.2.14+dfsg-0+deb8u4) over (2:4.2.14+dfsg-0+deb8u2) ...
    Preparing to unpack .../libsmbclient_2%3a4.2.14+dfsg-0+deb8u4_armhf.deb ...
    Unpacking libsmbclient:armhf (2:4.2.14+dfsg-0+deb8u4) over (2:4.2.14+dfsg-0+deb8u2) ...
    Preparing to unpack .../samba-libs_2%3a4.2.14+dfsg-0+deb8u4_armhf.deb ...
    Unpacking samba-libs:armhf (2:4.2.14+dfsg-0+deb8u4) over (2:4.2.14+dfsg-0+deb8u2) ...
    Preparing to unpack .../samba-common_2%3a4.2.14+dfsg-0+deb8u4_all.deb ...
    Unpacking samba-common (2:4.2.14+dfsg-0+deb8u4) over (2:4.2.14+dfsg-0+deb8u2) ...
    Preparing to unpack .../wolfram-engine_11.0.1+2017031701_armhf.deb ...
    wolfram-eula license has already been accepted
    Unpacking wolfram-engine (11.0.1+2017031701) over (11.0.1+2017022002) ...
    Preparing to unpack .../gstreamer1.0-plugins-good_1.4.4-2+deb8u3_armhf.deb ...
    Unpacking gstreamer1.0-plugins-good:armhf (1.4.4-2+deb8u3) over (1.4.4-2+deb8u2) ...
    Preparing to unpack .../gstreamer1.0-plugins-bad_1.4.4-2.1+deb8u2_armhf.deb ...
    Unpacking gstreamer1.0-plugins-bad:armhf (1.4.4-2.1+deb8u2) over (1.4.4-2.1+deb8u1) ...
    Preparing to unpack .../gstreamer1.0-plugins-base_1.4.4-2+deb8u1_armhf.deb ...
    Unpacking gstreamer1.0-plugins-base:armhf (1.4.4-2+deb8u1) over (1.4.4-2) ...
    Preparing to unpack .../libgstreamer-plugins-bad1.0-0_1.4.4-2.1+deb8u2_armhf.deb ...
    Unpacking libgstreamer-plugins-bad1.0-0:armhf (1.4.4-2.1+deb8u2) over (1.4.4-2.1+deb8u1) ...
    Preparing to unpack .../libpam-runtime_1.1.8-3.1+deb8u2+rpi3_all.deb ...
    Unpacking libpam-runtime (1.1.8-3.1+deb8u2+rpi3) over (1.1.8-3.1+deb8u2+rpi1) ...
    Processing triggers for man-db (2.7.0.2-5) ...
    Processing triggers for hicolor-icon-theme (0.13-1) ...
    Processing triggers for shared-mime-info (1.3-1) ...
    Processing triggers for gnome-menus (3.13.3-6) ...
    Processing triggers for desktop-file-utils (0.22-1) ...
    Processing triggers for mime-support (3.58) ...
    Setting up libpam-runtime (1.1.8-3.1+deb8u2+rpi3) ...
    (Reading database ... 112361 files and directories currently installed.)
    Preparing to unpack .../alacarte_3.11.91-2+rpi4_all.deb ...
    Unpacking alacarte (3.11.91-2+rpi4) over (3.11.91-2+rpi2) ...
    Preparing to unpack .../gstreamer1.0-alsa_1.4.4-2+deb8u1_armhf.deb ...
    Unpacking gstreamer1.0-alsa:armhf (1.4.4-2+deb8u1) over (1.4.4-2) ...
    Preparing to unpack .../gstreamer1.0-x_1.4.4-2+deb8u1_armhf.deb ...
    Unpacking gstreamer1.0-x:armhf (1.4.4-2+deb8u1) over (1.4.4-2) ...
    Preparing to unpack .../libopenblas-base_0.2.12-1+rpi1_armhf.deb ...
    Unpacking libopenblas-base (0.2.12-1+rpi1) over (0.2.12-1) ...
    Preparing to unpack .../libpam-chksshpwd_1.1.8-3.1+deb8u2+rpi3_armhf.deb ...
    Unpacking libpam-chksshpwd:armhf (1.1.8-3.1+deb8u2+rpi3) over (1.1.8-3.1+deb8u2+rpi1) ...
    Preparing to unpack .../pi-greeter_0.4_armhf.deb ...
    Unpacking pi-greeter (0.4) over (0.3) ...
    Preparing to unpack .../archives/piclone_0.4_armhf.deb ...
    Unpacking piclone (0.4) over (0.3) ...
    Preparing to unpack .../pix-plym-splash_0.9_armhf.deb ...
    Unpacking pix-plym-splash (0.9) over (0.8) ...
    Preparing to unpack .../raspberrypi-sys-mods_20170313_all.deb ...
    Unpacking raspberrypi-sys-mods (20170313) over (20170302) ...
    Preparing to unpack .../realvnc-vnc-server_6.0.2.26558_armhf.deb ...
    
    (gconftool-2:18645): GConf-WARNING **: Client failed to connect to the D-BUS daemon:
    Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
    Unpacking realvnc-vnc-server (6.0.2.26558) over (6.0.2.25562) ...
    Preparing to unpack .../rpi-chromium-mods_20170317_armhf.deb ...
    Unpacking rpi-chromium-mods (20170317) over (20170213) ...
    Preparing to unpack .../wiringpi_2.44_armhf.deb ...
    Unpacking wiringpi (2.44) over (2.42) ...
    Preparing to unpack .../raspberrypi-ui-mods_1.20170315_all.deb ...
    Unpacking raspberrypi-ui-mods (1.20170315) over (1.20170301) ...
    Preparing to unpack .../raspi-config_20170307_all.deb ...
    Unpacking raspi-config (20170307) over (20170228) ...
    Processing triggers for gnome-menus (3.13.3-6) ...
    Processing triggers for desktop-file-utils (0.22-1) ...
    Processing triggers for mime-support (3.58) ...
    Processing triggers for hicolor-icon-theme (0.13-1) ...
    Processing triggers for man-db (2.7.0.2-5) ...
    Processing triggers for libc-bin (2.19-18+deb8u7) ...
    Processing triggers for gconf2 (3.2.6-3) ...
    Processing triggers for shared-mime-info (1.3-1) ...
    Processing triggers for systemd (215-17+deb8u6) ...
    Setting up libaudiofile1:armhf (0.3.6-2+deb8u2) ...
    Setting up libgstreamer1.0-0:armhf (1.4.4-2+deb8u1) ...
    Setting up libgstreamer-plugins-base1.0-0:armhf (1.4.4-2+deb8u1) ...
    Setting up libwbclient0:armhf (2:4.2.14+dfsg-0+deb8u4) ...
    Setting up samba-libs:armhf (2:4.2.14+dfsg-0+deb8u4) ...
    Setting up libsmbclient:armhf (2:4.2.14+dfsg-0+deb8u4) ...
    Setting up samba-common (2:4.2.14+dfsg-0+deb8u4) ...
    Setting up wolfram-engine (11.0.1+2017031701) ...
    Setting up gstreamer1.0-plugins-base:armhf (1.4.4-2+deb8u1) ...
    Setting up gstreamer1.0-plugins-good:armhf (1.4.4-2+deb8u3) ...
    Setting up libgstreamer-plugins-bad1.0-0:armhf (1.4.4-2.1+deb8u2) ...
    Setting up gstreamer1.0-plugins-bad:armhf (1.4.4-2.1+deb8u2) ...
    Setting up alacarte (3.11.91-2+rpi4) ...
    Setting up gstreamer1.0-alsa:armhf (1.4.4-2+deb8u1) ...
    Setting up gstreamer1.0-x:armhf (1.4.4-2+deb8u1) ...
    Setting up libopenblas-base (0.2.12-1+rpi1) ...
    update-alternatives: using /usr/lib/libblas/libblas.so.3 to provide /usr/lib/libblas.so.3 (libblas.so.3) in auto mode
    update-alternatives: using /usr/lib/lapack/liblapack.so.3 to provide /usr/lib/liblapack.so.3 (liblapack.so.3) in auto mode
    Setting up libpam-chksshpwd:armhf (1.1.8-3.1+deb8u2+rpi3) ...
    Installing new version of config file /etc/profile.d/sshpwd.sh ...
    Setting up pi-greeter (0.4) ...
    Setting up piclone (0.4) ...
    Setting up pix-plym-splash (0.9) ...
    Setting up raspberrypi-sys-mods (20170313) ...
    Updating documentation URL in /boot/config.txt...
    Setting up realvnc-vnc-server (6.0.2.26558) ...
    Updating /etc/pam.d/vncserver
    Updating /etc/pam.conf... done
    Looking for font path... not found.
    Generating private key... done
    Installed systemd unit for VNC Server in Service Mode daemon
    Start or stop the service with:
      systemctl (start|stop) vncserver-x11-serviced.service
    Mark or unmark the service to be started at boot time with:
      systemctl (enable|disable) vncserver-x11-serviced.service
    
    Installed systemd unit for VNC Server in Virtual Mode daemon
    Start or stop the service with:
      systemctl (start|stop) vncserver-virtuald.service
    Mark or unmark the service to be started at boot time with:
      systemctl (enable|disable) vncserver-virtuald.service
    
    
    (gconftool-2:19580): GConf-WARNING **: Client failed to connect to the D-BUS daemon:
    Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
    gconfd-2: no process found
    Setting up rpi-chromium-mods (20170317) ...
    Setting up wiringpi (2.44) ...
    Setting up raspberrypi-ui-mods (1.20170315) ...
    Setting up raspi-config (20170307) ...
    Processing triggers for libc-bin (2.19-18+deb8u7) ...
    root@signage:~# 
    
  • Reboot in case there are Kernel changes or library updates.
  • Strip extra packages that we’ll never use
    root@signage:~# apt-get remove --purge wolfram-engine cron logrotate dphys-swapfile xserver-common lightdm
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    The following packages were automatically installed and are no longer required:
      coinor-libipopt1 dc fontconfig-infinality fonts-droid fonts-roboto gtk2-engines-clearlookspix libboost-filesystem1.55.0
      libboost-program-options1.55.0 libboost-regex1.55.0 libffi5 libgmime-2.6-0 libmumps-seq-4.10.0 liboauth0 libraw10 libxfce4util-bin
      libxfce4util-common libxfce4util6 libxfconf-0-2 pi-greeter pimixer pipanel pishutdown pix-icons pix-plym-splash pixel-wallpaper point-rpi
      wolframscript xfconf
    Use 'apt-get autoremove' to remove them.
    The following packages will be REMOVED:
      dphys-swapfile* lightdm* logrotate* raspberrypi-ui-mods* wolfram-engine* xserver-common* xserver-xorg* xserver-xorg-core* xserver-xorg-input-all*
      xserver-xorg-input-libinput* xserver-xorg-video-fbdev* xserver-xorg-video-fbturbo*
    0 upgraded, 0 newly installed, 12 to remove and 0 not upgraded.
    After this operation, 693 MB disk space will be freed.
    Do you want to continue? [Y/n] y
    (Reading database ... 112367 files and directories currently installed.)
    Removing dphys-swapfile (20100506-1) ...
    Purging configuration files for dphys-swapfile (20100506-1) ...
    Removing raspberrypi-ui-mods (1.20170315) ...
    update-alternatives: using /usr/bin/startlxde to provide /usr/bin/x-session-manager (x-session-manager) in auto mode
    update-alternatives: using /usr/share/libgksu/debian/gconf-defaults.libgksu-su to provide /usr/share/gconf/defaults/10_libgksu (libgksu-gconf-defaults) in auto mode
    Purging configuration files for raspberrypi-ui-mods (1.20170315) ...
    Removing lightdm (1.10.3-3+rpi) ...
    Purging configuration files for lightdm (1.10.3-3+rpi) ...
    Removing user `lightdm' ...
    Warning: group `lightdm' has no more members.
    Done.
    Removing logrotate (3.8.7-1) ...
    Purging configuration files for logrotate (3.8.7-1) ...
    Removing wolfram-engine (11.0.1+2017031701) ...
    Purging configuration files for wolfram-engine (11.0.1+2017031701) ...
    Removing xserver-xorg (1:7.7+16) ...
    Purging configuration files for xserver-xorg (1:7.7+16) ...
    Removing xserver-xorg-video-fbturbo (1.20161111~122359) ...
    Removing xserver-xorg-video-fbdev (1:0.4.4-1+rpi2) ...
    Removing xserver-xorg-input-all (1:7.7+16) ...
    Removing xserver-xorg-input-libinput (0.20.0-1) ...
    Removing xserver-xorg-core (2:1.18.4-2+rpi1) ...
    Purging configuration files for xserver-xorg-core (2:1.18.4-2+rpi1) ...
    rm: cannot remove ‘/var/log/Xorg.*.log.old’: No such file or directory
    Removing xserver-common (2:1.18.4-2+rpi1) ...
    Processing triggers for man-db (2.7.0.2-5) ...
    Processing triggers for gnome-menus (3.13.3-6) ...
    Processing triggers for desktop-file-utils (0.22-1) ...
    Processing triggers for mime-support (3.58) ...
    Processing triggers for shared-mime-info (1.3-1) ...
    Processing triggers for hicolor-icon-theme (0.13-1) ...
    root@signage:~# apt-get autoremove 
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    The following packages will be REMOVED:
      coinor-libipopt1 dc fontconfig-infinality fonts-droid fonts-roboto gtk2-engines-clearlookspix libboost-filesystem1.55.0
      libboost-program-options1.55.0 libboost-regex1.55.0 libepoxy0 libevdev2 libffi5 libgmime-2.6-0 libinput-bin libinput10 liblightdm-gobject-1-0
      libmumps-seq-4.10.0 liboauth0 libpciaccess0 libraw10 libwacom-common libwacom2 libxfce4util-bin libxfce4util-common libxfce4util6 libxfconf-0-2
      lightdm-gtk-greeter pi-greeter pimixer pipanel pishutdown pix-icons pix-plym-splash pixel-wallpaper point-rpi wolframscript xfconf
    0 upgraded, 0 newly installed, 37 to remove and 0 not upgraded.
    After this operation, 65.2 MB disk space will be freed.
    Do you want to continue? [Y/n] y
    (Reading database ... 102396 files and directories currently installed.)
    Removing coinor-libipopt1 (3.11.9-2) ...
    Removing dc (1.06.95-9) ...
    Removing fontconfig-infinality (20130104-0ubuntu0ppa1+rpi) ...
    Removing fonts-droid (1:4.4.4r2-6+rpi1) ...
    Removing fonts-roboto (1:4.4.4r2-6+rpi1) ...
    Removing gtk2-engines-clearlookspix:armhf (1:2.20.4) ...
    Removing wolframscript (1.0.1-19) ...
    Removing libboost-filesystem1.55.0:armhf (1.55.0+dfsg-3) ...
    Removing libboost-program-options1.55.0:armhf (1.55.0+dfsg-3) ...
    Removing libboost-regex1.55.0:armhf (1.55.0+dfsg-3) ...
    Removing libepoxy0 (1.2-1) ...
    Removing libinput10:armhf (1.5.0-1) ...
    Removing libevdev2 (1.3+dfsg-1) ...
    Removing libffi5:armhf (3.0.10-3+rpi1) ...
    Removing libgmime-2.6-0:armhf (2.6.20-1) ...
    Removing libinput-bin (1.5.0-1) ...
    Removing pi-greeter (0.4) ...
    update-alternatives: using /usr/share/xgreeters/lightdm-gtk-greeter.desktop to provide /usr/share/xgreeters/lightdm-greeter.desktop (lightdm-greeter) in auto mode
    Removing lightdm-gtk-greeter (1.8.5-2) ...
    Removing liblightdm-gobject-1-0 (1.10.3-3+rpi) ...
    Removing libmumps-seq-4.10.0 (4.10.0.dfsg-3+b2) ...
    Removing liboauth0:armhf (1.0.1-1) ...
    Removing libpciaccess0:armhf (0.13.2-3) ...
    Removing libraw10:armhf (0.16.0-9+deb8u2) ...
    Removing libwacom2:armhf (0.22-1) ...
    Removing libwacom-common (0.22-1) ...
    Removing libxfce4util-bin (4.10.1-2) ...
    Removing pimixer (0.20160527~090638-1) ...
    Removing libxfconf-0-2 (4.10.0-3) ...
    Removing xfconf (4.10.0-3) ...
    Removing libxfce4util6 (4.10.1-2) ...
    Removing libxfce4util-common (4.10.1-2) ...
    Removing pipanel (20161206~130650) ...
    Removing pishutdown (0.7) ...
    Removing 'diversion of /usr/bin/lxde-pi-shutdown-helper to /usr/bin/lxde-pi-shutdown-helper.old by pishutdown'
    Removing pix-icons (0.4) ...
    Removing pix-plym-splash (0.9) ...
    Removing pixel-wallpaper (0.3) ...
    Removing point-rpi (0.20160905) ...
    Processing triggers for libc-bin (2.19-18+deb8u7) ...
    Processing triggers for install-info (5.2.0.dfsg.1-6) ...
    Processing triggers for man-db (2.7.0.2-5) ...
    Processing triggers for fontconfig (2.11.0-6.3+deb8u1) ...
    Processing triggers for shared-mime-info (1.3-1) ...
    Processing triggers for hicolor-icon-theme (0.13-1) ...
    Processing triggers for udev (215-17+deb8u6) ...
    Processing triggers for gnome-menus (3.13.3-6) ...
    Processing triggers for desktop-file-utils (0.22-1) ...
    Processing triggers for mime-support (3.58) ...
    root@signage:~# 
    root@signage:~# insserv -r x11-common; apt-get autoremove --purge
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    root@signage:~# 
    
  • Replace log management with busybox logger. This will put log into circular memory buffer, you will able to see log using “logread” command.
    root@signage:~# apt-get install busybox-syslogd; dpkg --purge rsyslog
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    The following extra packages will be installed:
      busybox
    The following packages will be REMOVED:
      rsyslog
    The following NEW packages will be installed:
      busybox busybox-syslogd
    0 upgraded, 2 newly installed, 1 to remove and 0 not upgraded.
    Need to get 396 kB of archives.
    After this operation, 714 kB disk space will be freed.
    Do you want to continue? [Y/n] y
    Get:1 http://mirrordirector.raspbian.org/raspbian/ jessie/main busybox armhf 1:1.22.0-9+deb8u1 [373 kB]
    Get:2 http://mirrordirector.raspbian.org/raspbian/ jessie/main busybox-syslogd all 1:1.22.0-9+deb8u1 [23.4 kB]
    Fetched 396 kB in 1s (352 kB/s)            
    (Reading database ... 100170 files and directories currently installed.)
    Removing rsyslog (8.4.2-1+deb8u2) ...
    Processing triggers for man-db (2.7.0.2-5) ...
    Selecting previously unselected package busybox.
    (Reading database ... 100122 files and directories currently installed.)
    Preparing to unpack .../busybox_1%3a1.22.0-9+deb8u1_armhf.deb ...
    Unpacking busybox (1:1.22.0-9+deb8u1) ...
    Selecting previously unselected package busybox-syslogd.
    Preparing to unpack .../busybox-syslogd_1%3a1.22.0-9+deb8u1_all.deb ...
    Unpacking busybox-syslogd (1:1.22.0-9+deb8u1) ...
    Processing triggers for man-db (2.7.0.2-5) ...
    Processing triggers for systemd (215-17+deb8u6) ...
    Setting up busybox (1:1.22.0-9+deb8u1) ...
    Setting up busybox-syslogd (1:1.22.0-9+deb8u1) ...
    Processing triggers for systemd (215-17+deb8u6) ...
    (Reading database ... 100143 files and directories currently installed.)
    Removing rsyslog (8.4.2-1+deb8u2) ...
    Purging configuration files for rsyslog (8.4.2-1+deb8u2) ...
    root@signage:~# 
  • Disable swap and filesystem check and make the system read-only. Edit /boot/cmdline.txt and add “fastboot noswap ro” to the end of the line (see below) to disable filesystem check at boot, turn off swap file usage and make the system read-only.
    dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait fastboot noswap ro
    
  • Move some system files to tmp filesystem
    root@signage:~# rm -rf /var/lib/dhcp/ /var/run /var/spool /var/lock /etc/resolv.conf
    root@signage:~# ln -s /tmp /var/lib/dhcp
    root@signage:~# ln -s /tmp /var/run
    root@signage:~# ln -s /tmp /var/spool
    root@signage:~# ln -s /tmp /var/lock
    root@signage:~# touch /tmp/dhcpcd.resolv.conf; ln -s /tmp/dhcpcd.resolv.conf /etc/resolv.conf
    root@signage:~# 
    
  • The systemd file “random-seed” needs to be moved to a tmp filesystem as well. So do the following changes
    root@signage:~# rm /var/lib/systemd/random-seed
    root@signage:~# ln -s /tmp/random-seed /var/lib/systemd/random-seed
    root@signage:~# 
    
  • A small annoyance is the fact that sshd needs to read the logs and print out the Last Login information. We can disable that by modifying the file /etc/ssh/sshd_config and changing “PrintLastLog yes” to “PrintLastLog no”.
  • We also need to fix the DHCP startup script. Edit /etc/systemd/system/dhcpcd5 and change “PIDFile=/run/dhcpcd.pid” to “PIDFile=/var/run/dhcpcd.pid”. It should look like this when done:
    [Unit]
    Description=dhcpcd on all interfaces
    Wants=network.target
    Before=network.target
    
    [Service]
    Type=forking
    PIDFile=/var/run/dhcpcd.pid
    ExecStart=/sbin/dhcpcd -q -b
    ExecStop=/sbin/dhcpcd -x
    
    [Install]
    WantedBy=multi-user.target
    Alias=dhcpcd5
    
  • Now you need to fix the systemd service file to kickstart the random-seed service. For this we need to add the line ExecStartPre=/bin/echo "" >/tmp/random-seed to the service section of /lib/systemd/system/systemd-random-seed.service. The file will look like this once this is done:
    #  This file is part of systemd.
    #
    #  systemd is free software; you can redistribute it and/or modify it
    #  under the terms of the GNU Lesser General Public License as published by
    #  the Free Software Foundation; either version 2.1 of the License, or
    #  (at your option) any later version.
    
    [Unit]
    Description=Load/Save Random Seed
    Documentation=man:systemd-random-seed.service(8) man:random(4)
    DefaultDependencies=no
    RequiresMountsFor=/var/lib/systemd/random-seed
    Conflicts=shutdown.target
    After=systemd-readahead-collect.service systemd-readahead-replay.service systemd-remount-fs.service
    Before=sysinit.target shutdown.target
    
    [Service]
    Type=oneshot
    RemainAfterExit=yes
    ExecStartPre=/bin/echo "" >/tmp/random-seed
    ExecStart=/lib/systemd/systemd-random-seed load
    ExecStop=/lib/systemd/systemd-random-seed save
    
  • Run “systemctl daemon-reload” to reload and finalize the changes we just made.
  • Remove some of the startup scripts using “insserv -r bootlogs; insserv -r console-setup” and change the file /etc/fstab to reflect these changes. Mine looked like this to start with:
    proc            /proc           proc    defaults          0       0
    /dev/mmcblk0p1  /boot           vfat    defaults          0       2
    /dev/mmcblk0p2  /               ext4    defaults,noatime  0       1
    # a swapfile is not a swap partition, no line here
    #   use  dphys-swapfile swap[on|off]  for that
    
  • Now it looks like this:
    proc            /proc           proc    defaults             0       0
    /dev/mmcblk0p1  /boot           vfat    defaults,ro          0       2
    /dev/mmcblk0p2  /               ext4    defaults,noatime,ro  0       1
    # Our tmpfs filesystems. Everything else (above) is read only.
    # To set system to Read-Write use:
    # mount -o remount,rw /
    # and to set it back to Read-Only:
    # mount -o remount,ro /
    tmpfs           /tmp            tmpfs   nosuid,nodev         0       0
    tmpfs           /var/log        tmpfs   nosuid,nodev         0       0
    tmpfs           /var/tmp        tmpfs   nosuid,nodev         0       0
    
  • At this point you can reboot, BUT you’ll come back in read-only mode. You could continue and take the reboot later. To change the filesystem between read-only (ro) and read-write (rw) you can use “mount -o remount,rw /” and “mount -o remount,ro /” commands.
  • To make life simpler we add the following to the end of /etc/bash.bashrc to introduce the “rw” and “ro” aliases and add filesystem mode indication to the shell prompt:
    # set variable identifying the filesystem you work in (used in the prompt below)
    set_bash_prompt(){
        fs_mode=$(mount | sed -n -e "s/^\/dev\/.* on \/ .*(\(r[w|o]\).*/\1/p")
        PS1='\[\033[01;32m\]\u@\h${fs_mode:+($fs_mode)}\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    }
    
    alias ro='sudo mount -o remount,ro / ; sudo mount -o remount,ro /boot'
    alias rw='sudo mount -o remount,rw / ; sudo mount -o remount,rw /boot'
    alias reboot='sudo mount -o remount,rw / && history -a && sudo mount -o remount,ro / && sudo /sbin/reboot'
    
    # setup fancy prompt"
    PROMPT_COMMAND=set_bash_prompt
  • Also important is saving shell history before logout. So add the following to the file /etc/bash.bash_logout (it might not exist so create it):
    sudo mount -o remount,rw /
    history -a
    sudo fake-hwclock save
    sudo mount -o remount,ro /
    sudo mount -o remount,ro /boot
    
  • Okay so if you’ve made it this far you should be able to reboot and get a stable read-only system up and running after the reboot. Remember that “rw” and “ro” commands will allow you to toggle between read-only and read-write mode. I will not be mentioning this anymore after this point. You WILL need to be in read-write mode to perform the rest of these tutorial.
  • The main script that will run the show is below. Copy and paste it into /root/signage.sh (Yes, the name and location is very important as the script recursively calls itself. You can change this, but you need to edit the contents of the file aswell……you’ve been warned):
    #!/bin/bash
    ## OMXPlayer auto restart script
    ##
    ## Assign location of this script to variable
    ## Used to restart script after connection is lost
    signscript=/root/signage.sh
    
    ## Need this to kick omxplayer to play the stream when in background. If fifo pipe doesn't exist, create it.
    
    if [ ! -f /run/omxfifo ] ; then
    	mkfifo /run/omxfifo
    	chmod 700 /run/omxfifo
    fi
    
    ## If number of arguments is 0 then just start the default channel (equivalent to passing "fcad" as first argument).
    if [ $# -eq 0 ]
    then
    	/usr/bin/omxplayer -r --no-osd --no-keys --live -o both rtmp://blackwood.fcad.ryerson.ca:1935/fcadsignage/live /dev/null 2>&1 &
     echo -n '' > /run/omxfifo
    ## If first argument is "fcad" switch to fcadsignage (default) channel
    elif [[ "$1" == fcad ]]; then
    	/usr/bin/omxplayer -r --no-osd --no-keys --live -o both rtmp://blackwood.fcad.ryerson.ca:1935/fcadsignage/live /dev/null 2>&1 &
     echo -n '' > /run/omxfifo
    ## If first argument is "jrn" switch to jrnsignage channel
    elif [[ "$1" == jrn ]]; then
    	/usr/bin/omxplayer -r --no-osd --no-keys --live -o both rtmp://blackwood.fcad.ryerson.ca:1935/jrnsignage/live /dev/null 2>&1 & 
    echo -n '' > /run/omxfifo
    ## If first argument is "gcn1" switch to GCN channel
    elif [[ "$1" == gcn1 ]]; then
    	/usr/bin/omxplayer -r --no-osd --no-keys --live -o both rtmp://blackwood.fcad.ryerson.ca:1935/gcn1/live /dev/null 2>&1 & echo -
    n '' > /run/omxfifo
    ## If first argument is "gcn2" switch to RUTV channel
    elif [[ "$1" == gcn2 ]]; then
    	/usr/bin/omxplayer -r --no-osd --no-keys --live -o both rtmp://blackwood.fcad.ryerson.ca:1935/gcn2/live /dev/null 2>&1 & echo -
    n '' > /run/omxfifo
    ## If first argument is "sl1" switch to spiritlive1 channel
    elif [[ "$1" == sl1 ]]; then
    	/usr/bin/omxplayer -r --no-osd --no-keys --live -o both rtmp://blackwood.fcad.ryerson.ca:1935/spiritlive/live /dev/null 2>&1 & 
    echo -n '' > /run/omxfifo
    ## If first argument is "sl2" switch to spiritlive2 channel
    elif [[ "$1" == sl2 ]]; then
    	/usr/bin/omxplayer -r --no-osd --no-keys --live -o both rtmp://blackwood.fcad.ryerson.ca:1935/spiritlive/live1 /dev/null 2>&1 &
     echo -n '' > /run/omxfifo
    ## If first argument is anything else switch to Wowza's internal VOD sample stream
    else
    	/usr/bin/omxplayer -r --no-osd --no-keys --live -o both rtmp://blackwood.fcad.ryerson.ca:1935/vod/sample.mp4 /dev/null 2>&1 & e
    cho -n '' > /run/omxfifo
    fi
    
    sleep 0.2
    
    ## omxplayer.bin simply exits if the network dies. We need to monitor this and restart it.
    ## Loop to test if connection is present every 0.5 seconds
    while [ -n "$(/usr/bin/pgrep -f -u root omxplayer.bin)" ];
    do
    	sleep 0.5
    done
    
    
    ## If network connection connection dies execute this shell script itself (recursive) with the original 
    ## command line parameters (channel selection keyword) every 0.2 seconds until we are successful. As we 
    ## spawn new shells to execute the script the old shell is destroyed, so we don't have to worry about 
    ## running out of process space.
    sleep 0.2
    exec "$signscript" $@
    
  • Note that you can change the stream links above to whatever you want. Also the main if…elif…else…fi loop should be changed if you decide to use other command line parameters. But assuming you’re here and want to do a quick check, save the file (remember I’m assuming you’re in rw mode from here on), change it’s permissions via “chmod 700 signage.sh” and run it “./signage.sh”. Hopefully you have 5Mb/s bandwidth and in a few seconds can see the default signage from my school. If not stop here and troubleshoot the script. Use omxplayer from command line to see what’s going on.
  • Next we need to “teach” our FLIRC USB dongle what buttons do what. Grab the remote control you have and plugin the FLIRC dongle into a Mac or PC. Download the software to configure it from FLIRC’s website. Now use the software to configure the following correspondence:
    • F1 to 1 (on remote)
    • F2 to 2 (on remote)
    • ……
    • F10 to 0 (on remote)
  • You Can add more commands to the dongle later, this is just to get us started.
  • Take the dongle and plug it into the Pi. Run “thd –dump /dev/input/event0” and start pressing buttons on your remote. Did you get output like below (If yes continue, otherwise unplug all USB devices from the Pi and replug JUST the FLIRC into USB, this should force it to become “event0” input device)? Good……onwards……
  • Triggerhappy (thd) runs under nobody in raspbian, so we need to give nobody some special sudo privileges. There might be other ways to do this, but I found this simple enough. Create a new file “/etc/sudoers.d/020_nobody-nopasswd” with the following line in it:
    nobody ALL=(ALL) NOPASSWD: /usr/bin/pkill*,/bin/sleep*,/root/signage.sh*,/sbin/shutdown*,/bin/sync*
    
  • Now we need to tell thd what to do when we press buttons on our remote. Remember FLIRC turns IR commands to keyboard presses (F1-F10), so here we configure Triggerhappy to run commands based on buttons pushed (incidentally the commands in this file are the ones we specified above to allow nobody group to sudo. Anyways, edit /etc/triggerhappy/triggers.d/signage.conf” file and add the following contents to it:
    KEY_F1  1       sudo pkill -f -u root omxplayer.bin ; sudo pkill -f -u root signage.sh
    KEY_F1  0       sudo sleep 0.2 ; sudo /root/signage.sh fcad
    KEY_F2  1       sudo pkill -f -u root omxplayer.bin ; sudo pkill -f -u root signage.sh
    KEY_F2  0       sudo sleep 0.2 ; sudo /root/signage.sh jrn
    KEY_F3  1       sudo pkill -f -u root omxplayer.bin ; sudo pkill -f -u root signage.sh
    KEY_F3  0       sudo sleep 0.2 ; sudo /root/signage.sh gcn1
    KEY_F4  1       sudo pkill -f -u root omxplayer.bin ; sudo pkill -f -u root signage.sh
    KEY_F4  0       sudo sleep 0.2 ; sudo /root/signage.sh gcn2
    KEY_F5  1       sudo pkill -f -u root omxplayer.bin ; sudo pkill -f -u root signage.sh
    KEY_F5  0       sudo sleep 0.2 ; sudo /root/signage.sh sl1
    KEY_F6  1       sudo pkill -f -u root omxplayer.bin ; sudo pkill -f -u root signage.sh
    KEY_F6  0       sudo sleep 0.2 ; sudo /root/signage.sh sl2
    #KEY_F7 1       command
    #KEY_F7 0       command
    #KEY_F8 1       command
    #KEY_F8 0       command
    #KEY_F9 1       command
    #KEY_F9 0       command
    KEY_F10 1       sudo pkill -f -u root omxplayer.bin ; sudo pkill -f -u root signage.sh
    KEY_F10 0       sudo sleep 0.2 ; sudo /root/signage.sh sample
    
  • At this point if you want to auto start the signage at boot (with option to change the stream using remote) add the following line to your /etc/rc.local file:
  • We can take a reboot now and make sure things are working. Your default channel (from last step) should autoload now. You should also be able to switch channels using remote. If you disconnect the ethernet cable and reconnect it again later the same stream should continue playing.
  • You’re done……Congratulations. Might want to make a image of this microsd card and then run “rpi-update” to update to the latest firmware/kernel. This is sometimes risky hence why I said make a image first.

So over christmas holidays I spent about 5 days to perfect my raspberry pi based internet radio player.Screen Shot 2015-01-21 at 9.05.44 AM Screen Shot 2015-01-21 at 9.06.13 AM

You’ll need the following hardware:

  1. Raspberry Pi model B
  2. USB Wifi dongle (something that works with Raspbian would be nice). I got this one (http://www.adafruit.com/products/1030) from Adafruit.
  3. SD card (I’m using a 16GB card, but I think 8GB should be good to start with)
  4. Bluetooth 4.0 dongle. I’m using this one from ASUS (http://www.asus.com/ca-en/Networking/USBBT400/) that seems to work fine in Linux/Raspbian
  5. PiTFT resistive touch screen assembled from Adafruit (http://www.adafruit.com/products/1601)
  6. Pack of 20 tactile buttons from Adafruit (http://www.adafruit.com/products/1489) for the above screen (You need to solder these in…..very simple)
  7. Appropriate power USB power supply. Again I’m using the one from Adafruit (http://www.adafruit.com/products/501)
  8. Standard A to micro-B USB cable (http://www.adafruit.com/products/592)
  9. (optional) PiTFT Enclosure from Adafruit (http://www.adafruit.com/products/1892). Highly recommended as it looks really nice and clean.

 

The screen (PiTFT) comes pre-assembled so all you need to do is solder the 4 buttons on the bottom. This literally takes 5 minutes (8 solder points if you’re keeping track). Once that’s done plugin the screen onto the Pi.

Now grab a copy of the custom Raspbian image off Adafruits website (I’ve grabbed the 9/18/2014 image from http://adafruit-download.s3.amazonaws.com/PiTFT28R_raspbian140909_2014_09_18.zip). There might be a newer one out by the time you read this. Note that this image is only for TFT resistive touch screen NOT the capacitive screen. Unzip the above file (you’ll get a .img file) and burn it onto a SD card (mine is 16GB) following the instructions at http://elinux.org/RPi_Easy_SD_Card_Setup.

I’m plugging in the USB wifi and USB Bluetooth devices into the PI. Also plugin a wired ethernet connection (hopefully you have DHCP on it).

Let’s ssh to the Pi to get it setup (IP is on the PiTFT). I’m logging in as user pi (password raspberry……make sure you change it) and immediately switching to root.

At this point (as root) do the following tasks by running “raspy-config” and using the screenshots as reference:

  1. Expand the file system and reboot.
    Screen Shot 2015-01-21 at 9.27.59 AM
  2. Change the “pi” user passwordScreen Shot 2014-12-29 at 7.47.36 PM
  3. (Optional) Change the internationalization options.Screen Shot 2014-12-29 at 7.47.43 PM Screen Shot 2014-12-29 at 7.47.49 PM Screen Shot 2014-12-29 at 7.51.52 PMNOTE: On the following screen I leave en_GB.UTF-8 as default, although I live in Canada. But I do select _CA and _US as well.Screen Shot 2014-12-29 at 7.52.32 PMBack to main screen and we go back to Internationalization options to change the timezone.Screen Shot 2014-12-29 at 7.54.24 PM Screen Shot 2014-12-29 at 7.56.21 PM Screen Shot 2014-12-29 at 7.55.01 PM
  4. At this point you can also change the Hostname (Under advanced). Once you’ve done that, reboot for good measure and login using “pi” and sudo -i to get to root. Next we want to configure the WIFI USB device.

Now that we have the basics configured, before we install the wifi config tool, it’s a great time to take a break and do a “apt-get update ; apt-get upgrade” cycle. Next we want to make sure that both our USB dongles are detected (WIFI, Bluetooth) by doing “lsusb”.

Screen Shot 2014-12-29 at 8.21.25 PM

We now install wicd-curses using “apt-get install wicd-curses”. Then we run it and not touch anything, you need to press the right keys here. First right off the back press P(references). Note that It’s CAPITAL P.

 

Screen Shot 2014-12-29 at 8.22.10 PM Screen Shot 2014-12-29 at 8.29.52 PM

Once things are setup like the above picture, press F10 key to save it. You might lose connection, just wait until ssh times out and re-ssh back in and sudo -i as well. Now we need to get back into wicd-curses (if the connection dropped) and find the SSID for our WIFI. Once there DO NOT press ENTER. Highlight the entry by using the cursor keys (up,down) and press the RIGHT cursor key (—>) to open the prefs for that SSID. NOTE: the WPA ½ entry has been changed as well.

 

Screen Shot 2014-12-29 at 8.39.10 PM

Press F10 to save. You might get disconnected (you’ll see the WIFI LEDS flashing). If you got timed out, relogin and sudo -i to get root. reboot NOW. Now we need to disconnect the wired connection. This will force the system to turn on WIFI. Once the machine is booted (it might take a bit longer, since we have to wait for wired DHCP to time out), you’ll find the WIFI IP on the TFT.

SSH to the IP and get root shell. We now need to configure bluetooth. Follow along with the pics below. First though we need to install a bunch of stuff with “apt-get install bluetooth bluez bluez-utils bluez-alsa” command. Remove unnecessary services that got installed (scanner, printer, avahi) and disable their autostart.

Screen Shot 2014-12-29 at 9.11.44 PM
Add the following Disable/Enable block (2 lines) to the [General] section of /etc/bluetooth/audio.conf file.
Screen Shot 2014-12-29 at 9.14.21 PM
Okay we need to reboot now and once back in continue as root. First we make sure our BT device is initialized.
Screen Shot 2014-12-29 at 9.22.32 PM
Then we turn on the BT speaker (BeatsPill) and put it in discover mode (hold the b button until the bluetooth LED on the back starts flashing…..might have to push the b button once before). Then we go on to discover the device.
Screen Shot 2014-12-29 at 9.23.18 PM
Note it’s address. We will need to copy and paste it into the next few commands. Put the following in /etc/asound.conf paying attention to replace the MAC address of the BD device with the correct one you copied in the last step.
Screen Shot 2014-12-30 at 12.36.55 AMScreen Shot 2014-12-29 at 9.25.46 PM
Once we get the output 1 from the last command it means that the device is trusted now and Linux will try to auto connect to it if the BT speaker is on when the machine is rebooted. You’ll also hear a beep when the bluetooth-agent command successfully connects. In the last step I’m just trying to establish an audio connection by restarting the bluetooth daemon (make it forget the connection) and using bluez-test-audio to connect back to the speaker. Again you’ll hear a beep when the Pi connects.
Screen Shot 2014-12-29 at 9.28.25 PM
Now we need to install mpd, mpc and the curses based ncmpcpp by using “apt-get install mpd mpc ncmpcpp”.
Once that’s done copy /etc/mpd.conf to /etc/mpd.conf.old and create /etc/mpd.conf with the following content:
# An example configuration file for MPD
# See the mpd.conf man page for a more detailed description of each parameter.
# Files and directories #######################################################
#
# This setting controls the top directory which MPD will search to discover the
# available audio files and add them to the daemon's online database. This 
# setting defaults to the XDG directory, otherwise the music directory will be
# be disabled and audio files will only be accepted over ipc socket (using
# file:// protocol) or streaming files over an accepted protocol.
#
music_directory	"/var/lib/mpd/music"
#
# This setting sets the MPD internal playlist directory. The purpose of this
# directory is storage for playlists created by MPD. The server will use 
# playlist files not created by the server but only if they are in the MPD
# format. This setting defaults to playlist saving being disabled.
#
playlist_directory	"/var/lib/mpd/playlists"
#
# This setting sets the location of the MPD database. This file is used to
# load the database at server start up and store the database while the 
# server is not up. This setting defaults to disabled which will allow
# MPD to accept files over ipc socket (using file:// protocol) or streaming
# files over an accepted protocol.
#
db_file	"/var/lib/mpd/tag_cache"
# 
# These settings are the locations for the daemon log files for the daemon.
# These logs are great for troubleshooting, depending on your log_level
# settings.
#
# The special value "syslog" makes MPD use the local syslog daemon. This
# setting defaults to logging to syslog, otherwise logging is disabled.
#
log_file	"/var/log/mpd/mpd.log"
#
# This setting sets the location of the file which stores the process ID
# for use of mpd --kill and some init scripts. This setting is disabled by
# default and the pid file will not be stored.
#
pid_file	"/var/run/mpd/pid"
#
# This setting sets the location of the file which contains information about
# most variables to get MPD back into the same general shape it was in before
# it was brought down. This setting is disabled by default and the server 
# state will be reset on server start up.
#
state_file	"/var/lib/mpd/state"
#
# The location of the sticker database.  This is a database which
# manages dynamic information attached to songs.
#
sticker_file                   "/var/lib/mpd/sticker.sql"
#
###############################################################################
# General music daemon options ################################################
#
# This setting specifies the user that MPD will run as. MPD should never run as
# root and you may use this setting to make MPD change its user ID after
# initialization. This setting is disabled by default and MPD is run as the
# current user.
#
user	"mpd"
#
# This setting specifies the group that MPD will run as. If not specified
# primary group of user specified with "user" setting will be used (if set).
# This is useful if MPD needs to be a member of group such as "audio" to
# have permission to use sound card.
#
#group                          "nogroup"
#
# This setting sets the address for the daemon to listen on. Careful attention
# should be paid if this is assigned to anything other then the default, any.
# This setting can deny access to control of the daemon. Choose any if you want
# to have mpd listen on every address
#
# For network
#bind_to_address	"any"
bind_to_address	“127.0.0.1"
#
# And for Unix Socket
#bind_to_address	"/var/run/mpd/socket"
#
# This setting is the TCP port that is desired for the daemon to get assigned
# to.
#
port	"6600"
#
# This setting controls the type of information which is logged. Available 
# setting arguments are "default", "secure" or "verbose". The "verbose" setting
# argument is recommended for troubleshooting, though can quickly stretch
# available resources on limited hardware storage.
#
#log_level	"default"
#
# If you have a problem with your MP3s ending abruptly it is recommended that 
# you set this argument to "no" to attempt to fix the problem. If this solves
# the problem, it is highly recommended to fix the MP3 files with vbrfix
# (available as vbrfix in the debian archive), at which
# point gapless MP3 playback can be enabled.
#
gapless_mp3_playback	"yes"
#
# This setting enables MPD to create playlists in a format usable by other
# music players.
#
#save_absolute_paths_in_playlists	"no"
#
# This setting defines a list of tag types that will be extracted during the 
# audio file discovery process. Optionally, 'comment' can be added to this
# list.
#
#metadata_to_use	"artist,album,title,track,name,genre,date,composer,performer,disc"
#
# This setting enables automatic update of MPD's database when files in 
# music_directory are changed.
#
auto_update    "yes"
#
# Limit the depth of the directories being watched, 0 means only watch
# the music directory itself.  There is no limit by default.
#
#auto_update_depth "3"
#
###############################################################################
# Symbolic link behavior ######################################################
#
# If this setting is set to "yes", MPD will discover audio files by following 
# symbolic links outside of the configured music_directory.
#
follow_outside_symlinks	"yes"
#
# If this setting is set to "yes", MPD will discover audio files by following
# symbolic links inside of the configured music_directory.
#
follow_inside_symlinks	"yes"
#
###############################################################################
# Zeroconf / Avahi Service Discovery ##########################################
#
# If this setting is set to "yes", service information will be published with
# Zeroconf / Avahi.
#
zeroconf_enabled	"yes"
#
# The argument to this setting will be the Zeroconf / Avahi unique name for
# this MPD server on the network.
#
zeroconf_name	"iradio"
#
###############################################################################
# Permissions #################################################################
#
# If this setting is set, MPD will require password authorization. The password
# can setting can be specified multiple times for different password profiles.
#
#password                        "password@read,add,control,admin"
#
# This setting specifies the permissions a user has who has not yet logged in. 
#
#default_permissions             "read,add,control,admin"
#
###############################################################################
# Input #######################################################################
#
input {
        plugin "curl"
#       proxy "proxy.isp.com:8080"
#       proxy_user "user"
#       proxy_password "password"
}
#
###############################################################################
# Audio Output ################################################################

# MPD supports various audio output types, as well as playing through multiple 
# audio outputs at the same time, through multiple audio_output settings 
# blocks. Setting this block is optional, though the server will only attempt
# autodetection for one sound card.
#
# See <http://mpd.wikia.com/wiki/Configuration#Audio_Outputs> for examples of 
# other audio outputs.
#
# An example of an ALSA output THIS IS THE DEFAULT:
#
audio_output {
type	"alsa"
name	"My ALSA Device"
device	"hw:0,0"	# optional
format	"44100:16:2"	# optional
mixer_device	"default"	# optional
mixer_control	"PCM"	# optional
mixer_index	"0"	# optional
}
#
# Example for Bluetooth A2DP
#
audio_output {
type            "alsa"
name            "ALSA"
format          "44100:16:2"    # optional
#options         "dev=dmixer"
device          "bluetooth"
}
#
# Enable FIFO Pipe for ncmpcpp Visualizer
#
audio_output {
    type                    "fifo"
    name                    "iradio"
    path                    "/tmp/mpd.fifo"
    format                  "44100:16:1"
}
#
# Example for USB class complaint Audio Card
#
#audio_output {
#	type	"alsa"
#	name	"Output"
#	device	"hw:0,0"	# optional
#	dsd_usb	"no"
#}
#
# An example of an OSS output:
#
#audio_output {
#	type	"oss"
#	name	"My OSS Device"
#	device	"/dev/dsp"	# optional
#	format	"44100:16:2"	# optional
#	mixer_device	"/dev/mixer"	# optional
#	mixer_control	"PCM"	# optional
#}
#
# An example of a shout output (for streaming to Icecast):
#
#audio_output {
#	type	"shout"
#	encoding	"ogg"	# optional
#	name	"My Shout Stream"
#	host	"localhost"
#	port	"8000"
#	mount	"/mpd.ogg"
#	password	"hackme"
#	quality	"5.0"
#	bitrate	"128"
#	format	"44100:16:1"
#	protocol	"icecast2"	# optional
#	user	"source"	# optional
#	description	"My Stream Description"	# optional
#	genre	"jazz"	# optional
#	public	"no"	# optional
#	timeout	"2"	# optional
#}
#
# An example of a recorder output:
#
#audio_output {
#       type            "recorder"
#       name            "My recorder"
#       encoder         "vorbis"                # optional, vorbis or lame
#       path            "/var/lib/mpd/recorder/mpd.ogg"
##      quality         "5.0"                   # do not define if bitrate is defined
#       bitrate         "128"                   # do not define if quality is defined
#       format          "44100:16:1"
#}
#
# An example of a httpd output (built-in HTTP streaming server):
#
#audio_output {
#	type	"httpd"
#	name	"My HTTP Stream"
#	encoder	"vorbis"	# optional, vorbis or lame
#	port	"8000"
#	quality	"5.0"	# do not define if bitrate is defined
#	bitrate	"128"	# do not define if quality is defined
#	format	"44100:16:1"
#}
#
# An example of a pulseaudio output (streaming to a remote pulseaudio server)
#
#audio_output {
#	type	"pulse"
#	name	"My Pulse Output"
#	server	"remote_server"	# optional
#	sink	"remote_server_sink"	# optional
#}
#
## Example "pipe" output:
#
#audio_output {
#	type	"pipe"
#	name	"my pipe"
#	command	"aplay -f cd 2>/dev/null"
## Or if you're want to use AudioCompress
#	command	"AudioCompress -m | aplay -f cd 2>/dev/null"
## Or to send raw PCM stream through PCM:
#	command	"nc example.org 8765"
#	format	"44100:16:2"
#}
#
## An example of a null output (for no audio output):
#
#audio_output {
#	type	"null"
#	name	"My Null Output"
#}
#
# This setting will change all decoded audio to be converted to the specified
# format before being passed to the audio outputs. By default, this setting is
# disabled.
#
#audio_output_format	"44100:16:2"
#
# If MPD has been compiled with libsamplerate support, this setting specifies 
# the sample rate converter to use.  Possible values can be found in the 
# mpd.conf man page or the libsamplerate documentation. By default, this is
# setting is disabled.
#
#samplerate_converter	"Fastest Sinc Interpolator"
#
###############################################################################
# Volume control mixer ########################################################
#
# These are the global volume control settings. By default, this setting will
# be detected to the available audio output device, with preference going to 
# hardware mixing. Hardware and software mixers for individual audio_output
# sections cannot yet be mixed.
#
# An example for controlling an ALSA, OSS or Pulseaudio mixer; If this
# setting is used other sound applications will be affected by the volume
# being controlled by MPD.
#
#mixer_type	"hardware"
#
# An example for controlling all mixers through software. This will control
# all controls, even if the mixer is not supported by the device and will not
# affect any other sound producing applications.
#
#mixer_type	"software"
#
# This example will not allow MPD to touch the mixer at all and will disable
# all volume controls.
#
#mixer_type	"disabled"
#mixer_type	"none"
#
###############################################################################
# Normalization automatic volume adjustments ##################################
#
# This setting specifies the type of ReplayGain to use. This setting can have
# the argument "album" or "track". See <http://www.replaygain.org> for more
# details. This setting is disabled by default.
#
#replaygain	"album"
#
# This setting sets the pre-amp used for files that have ReplayGain tags. By
# default this setting is disabled.
#
#replaygain_preamp	"0"
#
# This setting enables on-the-fly normalization volume adjustment. This will
# result in the volume of all playing audio to be adjusted so the output has 
# equal "loudness". This setting is disabled by default.
#
volume_normalization	"no"
#
###############################################################################
# MPD Internal Buffering ######################################################
#
# This setting adjusts the size of internal decoded audio buffering. Changing
# this may have undesired effects. Don't change this if you don't know what you
# are doing.
#
audio_buffer_size	"2048"
#
# This setting controls the percentage of the buffer which is filled before 
# beginning to play. Increasing this reduces the chance of audio file skipping, 
# at the cost of increased time prior to audio playback.
#
buffer_before_play	"20%"
#
###############################################################################
# Resource Limitations ########################################################
#
# These settings are various limitations to prevent MPD from using too many
# resources. Generally, these settings should be minimized to prevent security
# risks, depending on the operating resources.
#
#connection_timeout	"60"
#max_connections	"10"
#max_playlist_length	"16384"
#max_command_list_size	"2048"
#max_output_buffer_size	"8192"
#
###############################################################################
# Character Encoding ##########################################################
#
# If file or directory names do not display correctly for your locale then you 
# may need to modify this setting. After modification of this setting mpd 
# --create-db must be run to change the database.
#
filesystem_charset	"UTF-8"
#
# This setting controls the encoding that ID3v1 tags should be converted from.
#
id3v1_encoding	"UTF-8"
#
###############################################################################
# SIDPlay decoder #############################################################
#
# songlength_database:
#  Location of your songlengths file, as distributed with the HVSC.
#  The sidplay plugin checks this for matching MD5 fingerprints.
#  See http://www.c64.org/HVSC/DOCUMENTS/Songlengths.faq
#
# default_songlength:
#  This is the default playing time in seconds for songs not in the
#  songlength database, or in case you're not using a database.
#  A value of 0 means play indefinitely.
#
# filter:
#  Turns the SID filter emulation on or off.
#
#decoder {
#       plugin                  "sidplay"
#       songlength_database     "/media/C64Music/DOCUMENTS/Songlengths.txt"
#       default_songlength      "120"
#       filter "true"
#}
#
###############################################################################

There are 3 audio_output sections for the internal headphone jack, bluetooth audio and a third one for ncmpcpp’s spectrum analyzer (although I don’t use it in this project).

Next we need a playlist file in m3u format. You’ll find a good one below (contains di.fm, sky.fm, CBC and somafm AAC links). Copy this into /var/lib/mpd/playlist/something.m3u (remember the filename since we will then use mpc to load it):


http://pub6.di.fm/di_00sclubhits_aac
http://pub6.di.fm/di_ambient_aac
http://pub6.di.fm/di_bassnjackinhouse_aac
http://pub6.di.fm/di_bassline_aac
http://pub6.di.fm/di_bigbeat_aac
http://pub6.di.fm/di_bigroomhouse_aac
http://pub6.di.fm/di_breaks_aac
http://pub6.di.fm/di_chillhop_aac
http://pub6.di.fm/di_chilloutdreams_aac
http://pub6.di.fm/di_chillout_aac
http://pub6.di.fm/di_chillstep_aac
http://pub6.di.fm/di_chiptunes_aac
http://pub6.di.fm/di_classiceurodance_aac
http://pub6.di.fm/di_classiceurodisco_aac
http://pub6.di.fm/di_classictrance_aac
http://pub6.di.fm/di_classicvocaltrance_aac
http://pub6.di.fm/di_clubdubstep_aac
http://pub6.di.fm/di_club_aac
http://pub6.di.fm/di_cosmicdowntempo_aac
http://pub6.di.fm/di_darkdnb_aac
http://pub6.di.fm/di_darkpsytrance_aac
http://pub6.di.fm/di_deephouse_aac
http://pub6.di.fm/di_deepnudisco_aac
http://pub6.di.fm/di_deeptech_aac
http://pub6.di.fm/di_discohouse_aac
http://pub6.di.fm/di_djmixes_aac
http://pub6.di.fm/di_downtempolounge_aac
http://pub6.di.fm/di_drumandbass_aac
http://pub6.di.fm/di_drumstep_aac
http://pub6.di.fm/di_dub_aac
http://pub6.di.fm/di_dubstep_aac
http://pub6.di.fm/di_ebm_aac
http://pub6.di.fm/di_eclectronica_aac
http://pub6.di.fm/di_electro_aac
http://pub6.di.fm/di_electronicpioneers_aac
http://pub6.di.fm/di_electronics_aac
http://pub6.di.fm/di_electropop_aac
http://pub6.di.fm/di_electroswing_aac
http://pub6.di.fm/di_epictrance_aac
http://pub6.di.fm/di_eurodance_aac
http://pub6.di.fm/di_funkyhouse_aac
http://pub6.di.fm/di_futuregarage_aac
http://pub6.di.fm/di_futuresynthpop_aac
http://pub6.di.fm/di_gabber_aac
http://pub6.di.fm/di_glitchhop_aac
http://pub6.di.fm/di_goapsy_aac
http://pub6.di.fm/di_handsup_aac
http://pub6.di.fm/di_hardcore_aac
http://pub6.di.fm/di_harddance_aac
http://pub6.di.fm/di_hardstyle_aac
http://pub6.di.fm/di_hardtechno_aac
http://pub6.di.fm/di_house_aac
http://pub6.di.fm/di_jungle_aac
http://pub6.di.fm/di_latinhouse_aac
http://pub6.di.fm/di_liquiddnb_aac
http://pub6.di.fm/di_liquiddubstep_aac
http://pub6.di.fm/di_lounge_aac
http://pub6.di.fm/di_mainstage_aac
http://pub6.di.fm/di_minimal_aac
http://pub6.di.fm/di_moombahton_aac
http://pub6.di.fm/di_nightcore_aac
http://pub6.di.fm/di_nudisco_aac
http://pub6.di.fm/di_oldschoolacid_aac
http://pub6.di.fm/di_oldschoolhouse_aac
http://pub6.di.fm/di_oldschoolrave_aac
http://pub6.di.fm/di_classictechno_aac
http://pub6.di.fm/di_progressive_aac
http://pub6.di.fm/di_progressivepsy_aac
http://pub6.di.fm/di_psybient_aac
http://pub6.di.fm/di_psychill_aac
http://pub6.di.fm/di_russianclubhits_aac
http://pub6.di.fm/di_scousehouse_aac
http://pub6.di.fm/di_soulfulhouse_aac
http://pub6.di.fm/di_spacemusic_aac
http://pub6.di.fm/di_techhouse_aac
http://pub6.di.fm/di_techno_aac
http://pub6.di.fm/di_trance_aac
http://pub6.di.fm/di_trap_aac
http://pub6.di.fm/di_tribalhouse_aac
http://pub6.di.fm/di_ukgarage_aac
http://pub6.di.fm/di_umfradio_aac
http://pub6.di.fm/di_undergroundtechno_aac
http://pub6.di.fm/di_vocalchillout_aac
http://pub6.di.fm/di_vocallounge_aac
http://pub6.di.fm/di_vocaltrance_aac
http://pub7.radiotunes.com/radiotunes_00srnb_aac
http://pub7.radiotunes.com/radiotunes_60srock_aac
http://pub7.radiotunes.com/radiotunes_80sdance_aac
http://pub7.radiotunes.com/radiotunes_80srock_aac
http://pub7.radiotunes.com/radiotunes_hit90s_aac
http://pub7.radiotunes.com/radiotunes_90srnb_aac
http://pub7.radiotunes.com/radiotunes_beatles_aac
http://pub7.radiotunes.com/radiotunes_altrock_aac
http://pub7.radiotunes.com/radiotunes_rtambient_aac
http://pub7.radiotunes.com/radiotunes_americansongbook_aac
http://pub7.radiotunes.com/radiotunes_baroque_aac
http://pub7.radiotunes.com/radiotunes_bebop_aac
http://pub7.radiotunes.com/radiotunes_hit60s_aac
http://pub7.radiotunes.com/radiotunes_the80s_aac
http://pub7.radiotunes.com/radiotunes_bossanova_aac
http://pub7.radiotunes.com/radiotunes_cafedeparis_aac
http://pub7.radiotunes.com/radiotunes_rtchillout_aac
http://pub7.radiotunes.com/radiotunes_guitar_aac
http://pub7.radiotunes.com/radiotunes_classicalperiod_aac
http://pub7.radiotunes.com/radiotunes_classicalpianotrios_aac
http://pub7.radiotunes.com/radiotunes_christmas_aac
http://pub7.radiotunes.com/radiotunes_classicrap_aac
http://pub7.radiotunes.com/radiotunes_classicmotown_aac
http://pub7.radiotunes.com/radiotunes_classicrock_aac
http://pub7.radiotunes.com/radiotunes_clubbollywood_aac
http://pub7.radiotunes.com/radiotunes_christian_aac
http://pub7.radiotunes.com/radiotunes_country_aac
http://pub7.radiotunes.com/radiotunes_dancehits_aac
http://pub7.radiotunes.com/radiotunes_datempolounge_aac
http://pub7.radiotunes.com/radiotunes_davekoz_aac
http://pub7.radiotunes.com/radiotunes_discoparty_aac
http://pub7.radiotunes.com/radiotunes_downtempolounge_aac
http://pub7.radiotunes.com/radiotunes_dreamscapes_aac
http://pub7.radiotunes.com/radiotunes_edmfest_aac
http://pub7.radiotunes.com/radiotunes_eurodance_aac
http://pub7.radiotunes.com/radiotunes_hardrock_aac
http://pub7.radiotunes.com/radiotunes_hit70s_aac
http://pub7.radiotunes.com/radiotunes_holidaysmoothjazz_aac
http://pub7.radiotunes.com/radiotunes_indierock_aac
http://pub7.radiotunes.com/radiotunes_israelihits_aac
http://pub7.radiotunes.com/radiotunes_jazzclassics_aac
http://pub7.radiotunes.com/radiotunes_jpop_aac
http://pub7.radiotunes.com/radiotunes_lounge_aac
http://pub7.radiotunes.com/radiotunes_lovemusic_aac
http://pub7.radiotunes.com/radiotunes_meditation_aac
http://pub7.radiotunes.com/radiotunes_mellowjazz_aac
http://pub7.radiotunes.com/radiotunes_mellowsmoothjazz_aac
http://pub7.radiotunes.com/radiotunes_metal_aac
http://pub7.radiotunes.com/radiotunes_modernblues_aac
http://pub7.radiotunes.com/radiotunes_modernrock_aac
http://pub7.radiotunes.com/radiotunes_classical_aac
http://pub7.radiotunes.com/radiotunes_soundtracks_aac
http://pub7.radiotunes.com/radiotunes_mozart_aac
http://pub7.radiotunes.com/radiotunes_nature_aac
http://pub7.radiotunes.com/radiotunes_newage_aac
http://pub7.radiotunes.com/radiotunes_oldies_aac
http://pub7.radiotunes.com/radiotunes_oldschoolfunknsoul_aac
http://pub7.radiotunes.com/radiotunes_pianojazz_aac
http://pub7.radiotunes.com/radiotunes_popchristmas_aac
http://pub7.radiotunes.com/radiotunes_poppunk_aac
http://pub7.radiotunes.com/radiotunes_poprock_aac
http://pub7.radiotunes.com/radiotunes_reggaeton_aac
http://pub7.radiotunes.com/radiotunes_relaxation_aac
http://pub7.radiotunes.com/radiotunes_relaxingambientpiano_aac
http://pub7.radiotunes.com/radiotunes_relaxingexcursions_aac
http://pub7.radiotunes.com/radiotunes_romantica_aac
http://pub7.radiotunes.com/radiotunes_romantic_aac
http://pub7.radiotunes.com/radiotunes_rootsreggae_aac
http://pub7.radiotunes.com/radiotunes_russiandance_aac
http://pub7.radiotunes.com/radiotunes_russianpop_aac
http://pub7.radiotunes.com/radiotunes_salsa_aac
http://pub7.radiotunes.com/radiotunes_ska_aac
http://pub7.radiotunes.com/radiotunes_slowjams_aac
http://pub7.radiotunes.com/radiotunes_smoothbossanova_aac
http://pub7.radiotunes.com/radiotunes_smoothjazz247_aac
http://pub7.radiotunes.com/radiotunes_smoothjazz_aac
http://pub7.radiotunes.com/radiotunes_smoothlounge_aac
http://pub7.radiotunes.com/radiotunes_softrock_aac
http://pub7.radiotunes.com/radiotunes_solopiano_aac
http://pub7.radiotunes.com/radiotunes_tophits_aac
http://pub7.radiotunes.com/radiotunes_uptemposmoothjazz_aac
http://pub7.radiotunes.com/radiotunes_urbanjamz_aac
http://pub7.radiotunes.com/radiotunes_urbanpophits_aac
http://pub7.radiotunes.com/radiotunes_vocalchillout_aac
http://pub7.radiotunes.com/radiotunes_vocallounge_aac
http://pub7.radiotunes.com/radiotunes_vocalnewage_aac
http://pub7.radiotunes.com/radiotunes_vocalsmoothjazz_aac
http://pub7.radiotunes.com/radiotunes_world_aac
http://3023.live.streamtheworld.com:80/CBC_70S001_H_SC
http://9223.live.streamtheworld.com:80/CBC_80S001_H_SC
http://6093.live.streamtheworld.com:80/CBC_90S001_H_SC
http://6693.live.streamtheworld.com:3690/CBC_90S001_H_SC
http://1721.live.streamtheworld.com:80/CBC_ABORIG_H_SC
http://3163.live.streamtheworld.com:80/CBC_ADLTAL_H_SC
http://5853.live.streamtheworld.com:80/CBC_ADLTPO_H_SC
http://2903.live.streamtheworld.com:80/CBC_ALTCRY_H_SC
http://9233.live.streamtheworld.com:80/CBC_AMBIEN_H_SC
http://3143.live.streamtheworld.com:80/CBC_BAROQU_H_SC
http://2073.live.streamtheworld.com:80/CBC_BLCLAS_H_SC
http://2083.live.streamtheworld.com:80/CBC_BLUES1_H_SC
http://9213.live.streamtheworld.com:80/CBC_CANCOM_H_SC
http://1521.live.streamtheworld.com:80/CBC_CANSON_H_SC
http://4293.live.streamtheworld.com:80/CBC_CLSCRY_H_SC
http://1451.live.streamtheworld.com:3690/CBC_CLSCRY_H_SC
http://2953.live.streamtheworld.com:80/CBC_CONTRY_H_SC
http://2933.live.streamtheworld.com:80/CBC_ECLASS_H_SC
http://2062.live.streamtheworld.com:80/CBC_ELECTR_H_SC
http://2903.live.streamtheworld.com:80/CBC_GGSAMP_H_SC
http://2903.live.streamtheworld.com:80/CBC_HAROCK_H_SC
http://3023.live.streamtheworld.com:80/CBC_HIPHOP_H_SC
http://3163.live.streamtheworld.com:80/CBC_INDIE1_H_SC
http://2773.live.streamtheworld.com:80/CBC_JAZCDN_H_SC
http://2793.live.streamtheworld.com:80/CBC_JAZMAS_H_SC
http://2093.live.streamtheworld.com:80/CBC_JAZSMO_H_SC
http://2773.live.streamtheworld.com:80/CBC_JAZSON_H_SC
http://3413.live.streamtheworld.com:80/CBC_JUKEBO_H_SC
http://3153.live.streamtheworld.com:80/CBC_MODMAS_H_SC
http://3163.live.streamtheworld.com:80/CBC_OPERAT_H_SC
http://3153.live.streamtheworld.com:80/CBC_ORCHES_H_SC
http://3023.live.streamtheworld.com:80/CBC_PIANO1_H_SC
http://9233.live.streamtheworld.com:80/CBC_POP040_H_SC
http://1651.live.streamtheworld.com:80/CBC_R1_CGY_H_SC
http://2953.live.streamtheworld.com:80/CBC_R1_CHR_H_SC
http://3373.live.streamtheworld.com:80/CBC_R1_COR_H_SC
http://2073.live.streamtheworld.com:80/CBC_R1_EDM_H_SC
http://2783.live.streamtheworld.com:80/CBC_R1_EKW_H_SC
http://2913.live.streamtheworld.com:80/CBC_R1_FRD_H_SC
http://2893.live.streamtheworld.com:80/CBC_R1_GBA_H_SC
http://2093.live.streamtheworld.com:80/CBC_R1_GFA_H_SC
http://3383.live.streamtheworld.com:80/CBC_R1_HFX_H_SC
http://3593.live.streamtheworld.com:80/CBC_R1_INK_H_SC
http://1661.live.streamtheworld.com:80/CBC_R1_IQA_H_SC
http://3143.live.streamtheworld.com:80/CBC_R1_KAM_H_SC
http://9453.live.streamtheworld.com:80/CBC_R1_KEL_H_SC
http://3143.live.streamtheworld.com:80/CBC_R1_LDN_H_SC
http://1531.live.streamtheworld.com:80/CBC_R1_MCT_H_SC
http://6093.live.streamtheworld.com:80/CBC_R1_MTL_H_SC
http://3903.live.streamtheworld.com:3690/CBC_R1_MTL_H_SC
http://1591.live.streamtheworld.com:80/CBC_R1_N_MTL_H_SC
http://1671.live.streamtheworld.com:80/CBC_R1_OTT_H_SC
http://9453.live.streamtheworld.com:80/CBC_R1_PRG_H_SC
http://2953.live.streamtheworld.com:80/CBC_R1_QQU_H_SC
http://9453.live.streamtheworld.com:80/CBC_R1_REG_H_SC
http://3143.live.streamtheworld.com:80/CBC_R1_SNB_H_SC
http://6733.live.streamtheworld.com:80/CBC_R1_SNF_H_SC
http://2963.live.streamtheworld.com:3690/CBC_R1_SNF_H_SC
http://5463.live.streamtheworld.com:80/CBC_R1_SSK_H_SC
http://5463.live.streamtheworld.com:80/CBC_R1_SUD_H_SC
http://6093.live.streamtheworld.com:80/CBC_R1_SYD_H_SC
http://6693.live.streamtheworld.com:3690/CBC_R1_SYD_H_SC
http://1671.live.streamtheworld.com:80/CBC_R1_TBA_H_SC
http://6693.live.streamtheworld.com:80/CBC_R1_TOR_H_SC
http://1451.live.streamtheworld.com:3690/CBC_R1_TOR_H_SC
http://3903.live.streamtheworld.com:80/CBC_R1_VCR_H_SC
http://6093.live.streamtheworld.com:3690/CBC_R1_VCR_H_SC
http://1651.live.streamtheworld.com:80/CBC_R1_VIC_H_SC
http://2093.live.streamtheworld.com:80/CBC_R1_WDR_H_SC
http://1671.live.streamtheworld.com:80/CBC_R1_WHS_H_SC
http://1661.live.streamtheworld.com:80/CBC_R1_WPG_H_SC
http://2953.live.streamtheworld.com:80/CBC_R1_YKN_H_SC
http://1651.live.streamtheworld.com:80/CBC_R2CLAS_H_SC
http://9433.live.streamtheworld.com:80/CBC_R2_EDM_H_SC
http://3143.live.streamtheworld.com:80/CBC_R2_HFX_H_SC
http://8653.live.streamtheworld.com:80/CBC_R2_IET_H_SC
http://5523.live.streamtheworld.com:80/CBC_R2_IPT_H_SC
http://2073.live.streamtheworld.com:80/CBC_R2_TOR_H_SC
http://2793.live.streamtheworld.com:80/CBC_R2_VCR_H_SC
http://3023.live.streamtheworld.com:80/CBC_R2_WPG_H_SC
http://1942.live.streamtheworld.com:80/CBC_RBSOUL_H_SC
http://2973.live.streamtheworld.com:80/CBC_ROCK01_H_SC
http://2093.live.streamtheworld.com:80/CBC_ROCKCL_H_SC
http://1952.live.streamtheworld.com:80/CBC_SINSON_H_SC
http://2773.live.streamtheworld.com:80/CBC_WORLDM_H_SC
http://ice.somafm.com/bagel-64.aac
http://ice.somafm.com/beatblender-64.aac
http://uwstream2.somafm.com:2000
http://ice.somafm.com/bootliquor-64.aac
http://uwstream2.somafm.com:8048
http://ice.somafm.com/brfm-64.aac
http://ice.somafm.com/christmas-64.aac
http://ice.somafm.com/cliqhop-64.aac
http://ice.somafm.com/covers-64.aac
http://ice.somafm.com/deepspaceone-64.aac
http://ice.somafm.com/defcon-64.aac
http://uwstream2.somafm.com:8906
http://ice.somafm.com/digitalis-64.aac
http://ice.somafm.com/doomed-64.aac
http://uwstream2.somafm.com:8100
http://ice.somafm.com/dronezone-64.aac
http://ice.somafm.com/dubstep-64.aac
http://uwstream2.somafm.com:5106
http://ice.somafm.com/earwaves-64.aac
http://ice.somafm.com/folkfwd-64.aac
http://xstream1.somafm.com:3000
http://ice.somafm.com/groovesalad-64.aac
http://xstream1.somafm.com:8504
http://ice.somafm.com/illstreet-64.aac
http://xstream1.somafm.com:8070
http://ice.somafm.com/indiepop-64.aac
http://ice.somafm.com/jollysoul-64.aac
http://uwstream2.somafm.com:8808
http://ice.somafm.com/lush-64.aac
http://ice.somafm.com/missioncontrol-64.aac
http://ice.somafm.com/poptron-64.aac
http://xstream1.somafm.com:9010
http://ice.somafm.com/secretagent-64.aac
http://ice.somafm.com/sf1033-64.aac
http://ice.somafm.com/sonicuniverse-64.aac
http://xstream1.somafm.com:8200
http://ice.somafm.com/spacestation-64.aac
http://uwstream2.somafm.com:8854
http://ice.somafm.com/suburbsofgoa-64.aac
http://ice.somafm.com/thetrip-64.aac
http://uwstream2.somafm.com:2406
http://ice.somafm.com/u80s-64.aac
http://ice.somafm.com/xmasinfrisko-64.aac
http://ice.somafm.com/xmasrocks-64.aac

One last file we need to get setup is /etc/default/bluetooth and then we reboot (and make sure your BT speaker is in BT mode…..on the pill you need to press the big b button so the bluetooth LED turns on in the back).

Screen Shot 2014-12-29 at 10.09.06 PM

If you’ve made it this far, during the Pi boot cycle the Beatspill should have beeped signifying a bluetooth connection. Hopefully :-). If it doesn’t take the next step with the mpc commands. If it still doesn’t work after the mpc commands (to get mpd playing some streams) then something has gone wrong. You need to troubleshoot.
Now login and get to root shell and follow along for a quick audio test using mpc command.
Screen Shot 2014-12-30 at 11.45.47 AM
Hopefully you got everything working with BT and you’re hearing music now. If not, stop and do some googling. For sake of completeness I’ve put the commands I usually use to troubleshoot. Basically find the Beatspill MAC address, try connecting to it (mine barfs in the picture below since it’s already connected), disconnect and reconnect. Kick mpd since it can loose it’s mind if you take the audio interface away. Once mpd has restarted, get mpc to kick off the tunes by tuning into item 99 from the playlist (yeah I like the 80’s).
Screen Shot 2014-12-30 at 11.52.25 AM
Next we need to install python-pip (to get the “pip” command). Use “apt-get install python-pip” to install it (don’t worry about version 2.6 install of python, python 2.7 will still be the default).
Screen Shot 2014-12-30 at 3.04.15 PM
Okay, this next bit is a bit hairy. You need to follow it right until I finish editing /etc/modprobe.d/raspi-blacklist.conf and only then do you reboot……If you reboot like the picture shows below, you’ll end up with a white screen on the PiTFT. The Pi is still working, so worst case, put up with the white PiTFT screen, ssh, and make the three changes to the three files in /etc and give it another reboot…..and viola, PiTFT should be back and good to go. So lets update everything by doing the 3 commands in the below picture. REMEMBER DO NOT REBOOT…..KEEP GOING AND EDIT THE NEXT 3 FILES, THEN REBOOT.
Screen Shot 2014-12-30 at 2.51.49 PM Screen Shot 2014-12-29 at 11.39.14 PM
Add ipv6, stmpe_device, gpio_backlight_device, gpio_keys, gpio_keys_device and btusb to /etc/modules to make the kernel load them. We need these for later when we play around with the buttons using triggerhappy service. You don’t strictly need ipv6, but heck it might be useful later.
Screen Shot 2014-12-30 at 11.29.30 AM
Next we set the options for the modules we’re loading. If your took the reboot too soon and you screen went white the problem is this file. Note that I’ve commented the first line and put in the second line (I believe adafruit had their TFT named in their kernel module, but after the kernel update — above — the new module has pitft instead. There are some comments in there as well to explain the GPIO button assignment and it’s interface with triggerhappy (later).
Screen Shot 2014-12-31 at 4.09.58 PM
This file just needs a single comment. You’ll see later why we need this.
Screen Shot 2014-12-30 at 11.33.21 AM
Okay….still with me…..good. Now we need to configure the triggerhappy service so it can respond to the four PiTFT buttons.
Screen Shot 2014-12-30 at 12.44.21 PM
I’ve configured the buttons as (from left to right):
  1. shutdown -h now
  2. mpc play and start the pygame graphical UI (does not come up at boot. Only when you press this button). More on this later, below.
  3. mpc play and mpc prev. This button starts playing and then goes to the previous playlist item (previous radio station). The mpc play is not crucial. I just have it there to force start mpd if it’s not already playing something.
  4. mpc play and mpc next. This button starts playing and then goes to the next playlist item (next radio station). The mpc play is not crucial. I just have it there to force start mpd if it’s not already playing something.

If you want to configure your own commands you need the appropriate KEY_XXXX kernel strings and the key numbers are at this website (https://github.com/torvalds/linux/blob/master/include/uapi/linux/input.h). The numbers are options in /etc/modprobe.d/adafruit.conf file and the corresponding KEY_XXXX entries end up in /etc/triggerhappy/triggers.d/mpc.conf. More info on gpio_keys_device module is here (https://github.com/notro/fbtft_tools/wiki/gpio_keys_device). A good reference for triggerhappy and other PiTFT stuff is here (https://github.com/notro/fbtft/wiki/FBTFT-shield-image), under triggerhappy (thd) heading. Also check out the man pages for thd.

We also need to modify the system startup script for triggerhappy so that it starts as user root (by default it starts as nobody). If we don’t do this we will not be able to run our nice ui python file later on from the buttons. Make the changes to DAEMON_ARGS variable (I’ve commented the original in the pic below), change “nobody” to “root”.
Screen Shot 2014-12-30 at 3.29.49 PM
In the next step we’ll reconfigure the init process to bypass login on console 1 (on PiTFT) and disable all the other consoles (we’re not using them and they waste memory). Once login has been bypassed we can freely run ncmpcpp on the PiTFT during boot. For this we need to create two files in /root. First /root/.ncmpcpp/config and then a shell script (don’t forget to chmod 700 it so you can execute it) called ncmpcpp.sh which we’ll call from /etc/inittab later.
Screen Shot 2014-12-30 at 1.02.11 PMScreen Shot 2014-12-30 at 1.06.32 PM
Note: MAKE SURE YOU “chmod 700 /root/ncmpcpp.sh”, otherwise you could end up with a infinite boot loop which is not fun.
Screen Shot 2014-12-30 at 1.13.58 PM
The contents of my /etc/inittab are here (be extremely careful when changing things in here).

# /etc/inittab: init(8) configuration.
# $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $
# The default runlevel.
id:2:initdefault:
# Boot-time system configuration/initialization script.
# This is run first except when booting in emergency (-b) mode.
si::sysinit:/etc/init.d/rcS
# What to do in single-user mode.
~~:S:wait:/sbin/sulogin
# /etc/init.d executes the S and K scripts upon change
# of runlevel.
#
# Runlevel 0 is halt.
# Runlevel 1 is single-user.
# Runlevels 2-5 are multi-user.
# Runlevel 6 is reboot.
l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6
# Normally not reached, but fallthrough in case of emergency.
z6:6:respawn:/sbin/sulogin
# What to do when CTRL-ALT-DEL is pressed.
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
# Action on special keypress (ALT-UpArrow).
#kb::kbrequest:/bin/echo "Keyboard Request--edit /etc/inittab to let this work."
# What to do when the power fails/returns.
pf::powerwait:/etc/init.d/powerfail start
pn::powerfailnow:/etc/init.d/powerfail now
po::powerokwait:/etc/init.d/powerfail stop
# /sbin/getty invocations for the runlevels.
#
# The "id" field MUST be the same as the last
# characters of the device (after "tty").
#
# Format:
#  :::
#
# Note that on most Debian systems tty7 is used by the X Window System,
# so if you want to add more getty's go ahead but skip tty7 if you run X.
#
1:2345:respawn:/sbin/getty  --skip-login --login-program /root/ncmpcpp.sh 38400 tty1 
#1:2345:respawn:/sbin/getty --autologin pi --noclear 38400 tty1 
#1:2345:respawn:/sbin/getty --noclear 38400 tty1 
#2:23:respawn:/sbin/getty 38400 tty2
#3:23:respawn:/sbin/getty 38400 tty3
#4:23:respawn:/sbin/getty 38400 tty4
#5:23:respawn:/sbin/getty 38400 tty5
#6:23:respawn:/sbin/getty 38400 tty6
# Example how to put a getty on a serial line (for a terminal)
#
#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
#T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100
# Example how to put a getty on a modem line.
#
#T3:23:respawn:/sbin/mgetty -x0 -s 57600 ttyS3
#Spawn a getty on Raspberry Pi serial line
#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

Now, once more, before we reboot and screw it all up make sure you can run /root/ncmpcpp from command line ssh. You should see a clock. Press “q” to exit. Good…..now reboot and hopefully if you didn’t screwup you should see a nice console screen with the clock on you PiTFT.

IMG_1467

 

I’m playing something here. You will need to give Wifi a chance to get settled before pressing the previous/next buttons (3rd and 4th buttons from the left).

Now lets move onto getting the second button to work (i.e. the nice pygame gui). The original source for this came from https://github.com/ISO-B/pmb-pitft. I’ve done a bunch of changes, since I use the Pi for radio only and radio stations do not adhere to the Artist – Title standard. You can use the original code, but since the program is not getting the right info the last.fm pics and the info are wrong. The other change I’ve done is show the artist picture from last.fm if the album information is missing — which is the case when you’re playing internet radio. Almost all radio stations I’ve come across show Artist – Song Title, not Album Name.
You can download my version (https://dl.dropboxusercontent.com/u/3665206/pmb-pitft.tgz) as a tar file and open it up in /home/pi/ folder using “tar -zxvf ./pmb-pitft.tgz” (assuming the file is in /home/pi to start the tar extraction).
You’ll also need the pylast library to get lastfm information, so lets install it using “apt-get install python-pylast”. Once that’s done edit the ui.py file (in /home/pi/pmb-pitft/pmb-pitft folder) and change the API_KEY, API_SECRET, username and password to your accounts credentials (API_KEY and API_SECRET are at http://www.last.fm/api/account once you login to your account).
Screen Shot 2014-12-30 at 3.16.25 PM
Now let’s make sure the extraction went okay. Assuming you’ve followed my instructions if you issue “/usr/bin/python /home/pi/pmb-pitft/pmb-pitft/ui.py” from /home/pi folder, you should see a nice gui on pitft like below.
IMG_1469
Make sure this command works, since our 2nd button on pitft is hardwired to run this command when you press it.
Okay assuming you’re still with me. One more thing we need to do is to change the console fonts to make the ncmpcpp “clock” screen a bit better looking. This is the standard procedure that’s explained in other places as well (adafruit). You need to run the command “dpkg-reconfigure console-setup” and follow the screens.
Screen Shot 2014-12-30 at 3.48.46 PM Screen Shot 2014-12-30 at 3.48.52 PM Screen Shot 2014-12-30 at 3.49.10 PM Screen Shot 2014-12-30 at 3.49.19 PM
Once this process finishes, you’ll end up with a clock startup screen like this.
IMG_1470
And again from left to right the buttons will do “Shutdown -h now”, pygame ui, Previous Song, Next Song. As I type this I’m getting bad sectors on the Pi (cheap SD card I guess), so I’m off to backup everything. You should do the same RIGHT NOW :-).
At this point you can go off exploring (You did create a backup right?). I would check out adafruits page on pitft resistive (https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi?view=all) and start paying attention about halfway down the page around “sudo reboot and look at the console output” paragraph (Just search for it on the page), where it starts talking about calibrating the screen for X and stuff. Frankly I found the default calibration pretty good.
For a really good web interface that literally takes 2 minutes to setup check out ympd (http://www.ympd.org/). It’s so simple (specially if you grab the precompiled executable), no configuration, no rocket science……oh and did I say it looks great :-).
ympd_playlist

Notes on getting the most out of Screenly OSE for Raspberry Pi

datePosted on 16:53, November 21st, 2013 by Many Ayromlou

For those that are not familiar, Screenly is a Digital Signage System for the Pi. There is a open source edition of it (OSE) that you can just download and install on your own SD card. I’ve been messing around with it for the past few days and it’s surprisingly simple and powerful. Below are some notes on how to fix various annoyances:

  • ON 1080p SCREENS ONLY!! Normally when you use the web browser portion of Screenly you’ll notice that it does not fill the screen (there is a black border around the screen). The video’s play fine though. For some reason on 1920×1080 screen X windows does not detect the right resolution. To force this you need to modify/uncomment the following lines in config.txt file on the dos partition of the SD card (normally mounted under /boot when the pi is running screenly).
    disable_overscan=1
    hdmi_group=1
    hdmi_mode=16
    
  • mkv files with mp4 essence seem to work fine. I added a new video asset and uploaded the file Tears of steel (HD 720p version) from blender foundation which seems to work once you turn it on. BTW, it takes a long time after the upload progress scroll bar reaches the end to actually get a Asset entry on the web interface. You need to be patient.
  • After playing around with http streaming of mp4 files (i.e: you create a URL asset and use the mp4 URL in the asset URL field and set the asset type to video), I thought about youtube. I’d come across a site in the past that would give you the mp4 direct download URL of any file hosted on youtube (if the mp4 file exists that is). So I dug around a bit and indeed it works. Here is how you go about it:
    • Go and find the youtube video you’re interested in using your browser.Screen Shot 2013-11-21 at 4.45.08 PM
    • Once you get to the video pause playback and change the URL of your browser and substitute ssyoutube instead of youtube (ie: if the video URL is http://youtube.com/djsalkjfklds change it by adding ss in front so the URL reads http://ssyoutube.com/djsalkjfklds) and load that page. Don’t worry about the “Get me out of here page that sometimes comes up” it’s just that if you’re logged into youtube is will use https instead of http. You can take the ‘s’ out if you like. Screen Shot 2013-11-21 at 4.47.54 PM
    • Now on this page (savefrom.net) right click on the mp4 720p (or 1080p if it exists) link and copy the link. Screen Shot 2013-11-21 at 4.49.20 PM
    • Back in the Screenly interface create a new asset and paste the URL you just copied into the Asset URL field and set the Asset Type to Video. Activate the asset and enjoy. Screen Shot 2013-11-21 at 4.52.33 PM
  • To make sure you’re up to date with all the fixes you can ssh to the pi login as pi user and run the “run_upgrade.sh” script in ~pi/screenly/misc folder.
  • The screenly guys have also added the ability to run stunnel on the device and create a tunnel between port 453 on the pi and port 8080 effectively giving you https secured connection. To turn this functionality on you need to run the “enable_ssl.sh” script in ~pi/screenly/misc folder. Don’t worry about the last error in this script. It’s just missing a closing quote mark on a print line.
  • You’ve noticed that there is no mechanism to password protect the Schedule overview page where the carousel is running. It’s a feature that’s on their radar and will land at some point. Until then I needed to somehow restrict access to this page so students/others couldn’t get in there and mess stuff up. So I decided to use the ufw (User Friendly Firewall) command to modify the iptables so that the webserver would only respond to request from a certain subnet. First you need to become root by “sudo -i” from the pi account. Then you can use the following commands to check the rules, delete the unnecessary ones and add the new one to restrict access to the web server. You could do this for ssh port 22 as well if you wanted:
    
    root@screenly:~# ufw status
    Status: active
    
    To                         Action      From
    --                         ------      ----
    22                         ALLOW       Anywhere
    8080/tcp                   ALLOW       Anywhere
    
    root@screenly:~# ufw delete allow 8080/tcp
    root@screenly:~# ufw allow from xx.yy.zz.0/24
    root@screenly:~# ufw status
    Status: active
    
    To                         Action      From
    --                         ------      ----
    22                         ALLOW       Anywhere
    Anywhere                   ALLOW       xx.yy.zz.0/24
    
  • More to come……

Streaming 1080P video using Raspberry Pi (or BeagleBone Black)

datePosted on 21:24, November 9th, 2013 by Many Ayromlou

I’ve finally got this project to a point were I can do a write up on it. The following hardware is needed:

  1. Raspberry Pi 512K version (or BeagleBone Black)
  2. Logitech C920 Webcam
  3. 16 GB micro SDHC card (can probably do it on 8GB too)
  4. Wireless dongle supported by linux (I’m using a TrendNet TEW-645UB which was pretty much plug and play)

The goal of this project is to get the following installed and configured:

  1. CRTMP streaming server
  2. C920 install and config (v4l2), ffmpeg installation, boneCV installation from Derek Molloy’s site
  3. configuring ddclient for dynamic DNS (optional)
  4. putting it all together and creating a webpage with embedded JWplayer to view the stream

UPDATE: Sound works now on BeagleBone Black. On Raspberry you will run into alsa buffer xruns. See below for updated streamVideoRTSP script.

What I still need to figure out is the sound off the camera. At the moment I got buttery smooth 1080P video off the Pi (on wired or wireless connection) running at 5Mb/s but the sound is yet to come.

0) Preparation:

So to prepare you need to get linux installed on your Pi or BBB (BeagleBone Black). I used the latest raspbian for the PI and BeageBone Black Ubuntu Raring 13.04 for BBB. Get it installed onto your SD card. If you use a larger than 8GB SD card you can follow the procedure below to expand the partition from 8GB to whatever your SD card can hold (mine is a 16GB card) (NOTE: almost all commands need to be executed as root so do a sudo -i to start with):

  • Use fdisk to see the partition table
    root@debian-armhf:/# fdisk /dev/mmcblk0
    
    Command (m for help): p
    
    Disk /dev/mmcblk0: 3947 MB, 3947888640 bytes
    4 heads, 16 sectors/track, 120480 cylinders, total 7710720 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x80000000
    
            Device Boot      Start         End      Blocks   Id  System
    /dev/mmcblk0p1   *        2048        4095        1024    1  FAT12
    /dev/mmcblk0p2            4096     3751935     1873920   83  Linux
  • In this case we’re expanding partition 2 by first deleting it and without writing the partition table recreating it to span the entire disk (and then writing the new partition table to SD card). This in effect expands the partition. We will expand the filesystem after reboot.
    Command (m for help): d
    Partition number (1-4): 2
    
    Command (m for help): p
    
    Disk /dev/mmcblk0: 3947 MB, 3947888640 bytes
    4 heads, 16 sectors/track, 120480 cylinders, total 7710720 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x80000000
    
            Device Boot      Start         End      Blocks   Id  System
    /dev/mmcblk0p1   *        2048        4095        1024    1  FAT12
    
    Command (m for help): 
    Command (m for help): n
    Partition type:
       p   primary (1 primary, 0 extended, 3 free)
       e   extended
    Select (default p): p
    Partition number (1-4, default 2): 2
    First sector (4096-7710719, default 4096): 
    Using default value 4096
    Last sector, +sectors or +size{K,M,G} (4096-7710719, default 7710719): 
    Using default value 7710719
    
    Command (m for help): p
    
    Disk /dev/mmcblk0: 3947 MB, 3947888640 bytes
    4 heads, 16 sectors/track, 120480 cylinders, total 7710720 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x80000000
    
            Device Boot      Start         End      Blocks   Id  System
    /dev/mmcblk0p1   *        2048        4095        1024    1  FAT12
    /dev/mmcblk0p2            4096     7710719     3853312   83  Linux
    
    Command (m for help): 
    Command (m for help): w
    
    The partition table has been altered!
    
    Calling ioctl() to re-read partition table.
    
    WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
    The kernel still uses the old table. The new table will be used at
    the next reboot or after you run partprobe(8) or kpartx(8)
    Syncing disks.
    root@debian-armhf:/# reboot
  • Once you’re back from reboot we need to expand the filesystem to cover the new partition. Don’t forget to sudo -i to become root.
    root@debian-armhf:/# df
    Filesystem     1K-blocks   Used Available Use% Mounted on
    rootfs           1811704 740184    977824  44% /
    /dev/root        1811704 740184    977824  44% /
    devtmpfs          253920      0    253920   0% /dev
    tmpfs              50816    216     50600   1% /run
    tmpfs               5120      0      5120   0% /run/lock
    tmpfs             101620      0    101620   0% /run/shm
    /dev/mmcblk0p1      1004    474       530  48% /boot/uboot
    root@debian-armhf:/# 
    
    root@debian-armhf:/# resize2fs /dev/mmcblk0p2 
    resize2fs 1.42.5 (29-Jul-2012)
    Filesystem at /dev/mmcblk0p2 is mounted on /; on-line resizing required
    old_desc_blocks = 1, new_desc_blocks = 1
    The filesystem on /dev/mmcblk0p2 is now 963328 blocks long.
    
    root@debian-armhf:/# df
    Filesystem     1K-blocks   Used Available Use% Mounted on
    rootfs           3761680 741096   2851404  21% /
    /dev/root        3761680 741096   2851404  21% /
    devtmpfs          253920      0    253920   0% /dev
    tmpfs              50816    216     50600   1% /run
    tmpfs               5120      0      5120   0% /run/lock
    tmpfs             101620      0    101620   0% /run/shm
    /dev/mmcblk0p1      1004    474       530  48% /boot/uboot
    root@debian-armhf:/# 

1) CRTMP Server installation

CRTMP server is a streaming media server very similar to wowza. I use this to point ffmpeg at and to get playback on JWplayer. Grab the source code and follow the instructions for installing it on Ubuntu from http://wiki.rtmpd.com/quickbuild. You will need to create your build environment before you start building so do the command below to setup your environment and get the prerequisites installed:

  • Install needed packages
    root@ubuntu-armhf:/# apt-get install g++ subversion cmake make libssl-dev
  • Run these two additional commands
    root@ubuntu-armhf:/# apt-get install libcurl4-openssl-dev pkg-config
    root@ubuntu-armhf:/# pkg-config openssl --cflags --libs
  • Make sure that the last commands output was “-lssl -lcrypto”
  • Fetch the latest repo version of CRTMP
    cd /opt
    svn co --username anonymous --password "" https://svn.rtmpd.com/crtmpserver/trunk crtmpserver
    cd /crtmpserver/builders/cmake/cmake_find_modules
  • Edit the file Find_openssl.cmake and add the following path to the PATHS section of ssl, crypto and z sections above /usr/lib64 line:
    /usr/lib/arm-linux-gnueabihf
  • Edit the file Find_pcap.cmake and add the following path to the PATHS section of pcap sections above /usr/lib64 line:
    /usr/lib/arm-linux-gnueabihf
  • Edit the file Find_dl.cmake and add the following path to the PATHS section of dl sections above /usr/lib64 line:
    /usr/lib/arm-linux-gnueabihf
  • Edit the file Find_lua.cmake and add the following path to the PATHS section of lua sections above /usr/lib64 line:
    /usr/lib/arm-linux-gnueabihf
  • Might have to do this if locale is giving you grief (Note: I’ve picked en_CA since I live in Canada, you need to pick the right one for your country/region):
    root@ubuntu-armhf:/opt/crtmpserver/builders/cmake/cmake_find_modules# sudo locale-gen en_CA en_CA.UTF-8
    
    Generating locales...
    
    en_CA.ISO-8859-1... done
    
    en_CA.UTF-8... done
    
    Generation complete.
    
    root@ubuntu-armhf:/opt/crtmpserver/builders/cmake/cmake_find_modules# dpkg-reconfigure locales
    
    Generating locales...
    
    en_CA.ISO-8859-1... up-to-date
    
    en_CA.UTF-8... up-to-date
    
    en_US.UTF-8... done
    
    Generation complete.
  • Start building crtmp
    root@ubuntu-armhf:/opt/crtmpserver/builders/cmake# ./run
    
  • This process will take a while……go have a couple of coffee’s and/or snacks

Once this process is finished you’ll end up with the executable in /opt/crtmpserver/builders/cmake/crtmpserver, but that’s not how you run it. First you need a config file — you can edit crtmpserver.lua in /opt/crtmpserver/builders/cmake/crtmpserver or save a copy of the original and create a new one with the content from below (I’ve just cleaned up the original a tiny bit).

-- Start of the configuration. This is the only node in the config file. 
-- The rest of them are sub-nodes
configuration=
{
	-- if true, the server will run as a daemon.
	-- NOTE: all console appenders will be ignored if this is a daemon
	daemon=false,
	-- the OS's path separator. Used in composing paths
	pathSeparator="/",

	-- this is the place where all the logging facilities are setted up
	-- you can add/remove any number of locations

	logAppenders=
	{
		{
			-- name of the appender. Not too important, but is mandatory
			name="console appender",
			-- type of the appender. We can have the following values:
			-- console, coloredConsole and file
			-- NOTE: console appenders will be ignored if we run the server
			-- as a daemon
			type="coloredConsole",
			-- the level of logging. 6 is the FINEST message, 0 is FATAL message.
			-- The appender will "catch" all the messages below or equal to this level
			-- bigger the level, more messages are recorded
			level=6
		},
		{
			name="file appender",
			type="file",
			level=6,
			-- the file where the log messages are going to land
			fileName="/tmp/crtmpserver",
			--newLineCharacters="\r\n",
			fileHistorySize=10,
			fileLength=1024*256,
			singleLine=true
		}
	},

	-- this node holds all the RTMP applications
	applications=
	{
		-- this is the root directory of all applications
		-- usually this is relative to the binary execuable
		rootDirectory="applications",

		--this is where the applications array starts
		{
			-- The name of the application. It is mandatory and must be unique 
			name="appselector",
			-- Short description of the application. Optional
			description="Application for selecting the rest of the applications",

			-- The type of the application. Possible values are:
			-- dynamiclinklibrary - the application is a shared library
			protocol="dynamiclinklibrary",
			-- the complete path to the library. This is optional. If not provided, 
			-- the server will try to load the library from here
			-- //lib.{so|dll|dylib}
			-- library="/some/path/to/some/shared/library.so"

			-- Tells the server to validate the clien's handshake before going further. 
			-- It is optional, defaulted to true
			validateHandshake=false,
			-- this is the folder from where the current application gets it's content.
			-- It is optional. If not specified, it will be defaulted to:
			-- //mediaFolder
			-- mediaFolder="/some/directory/where/media/files/are/stored"
			-- the application will also be known by that names. It is optional
			--aliases=
			--{
			--	"simpleLive",
			--	"vod",
			--	"live",
			--},
			-- This flag designates the default application. The default application
			-- is responsable of analyzing the "connect" request and distribute 
			-- the future connection to the correct application.
			default=true,
			acceptors = 
			{
				{
					ip="0.0.0.0",
					port=1935,
					protocol="inboundRtmp"
				},
				{
					ip="0.0.0.0",
					port=8081,
					protocol="inboundRtmps",
					sslKey="server.key",
					sslCert="server.crt"
				},
				{
					ip="0.0.0.0",
					port=8080,
					protocol="inboundRtmpt"
                },
			}
		},
		{
			description="FLV Playback Sample",
			name="flvplayback",
			protocol="dynamiclinklibrary",
			aliases=
			{
				"simpleLive",
				"vod",
				"live",
				"WeeklyQuest",
				"SOSample",
				"oflaDemo",
			},
			acceptors = 
			{
				{
					ip="0.0.0.0",
					port=6666,
					protocol="inboundLiveFlv",
					waitForMetadata=true,
				},
				{
					ip="0.0.0.0",
					port=9999,
					protocol="inboundTcpTs"
				},
				{
					ip="0.0.0.0",
					port=10000,
					protocol="inboundUdpTs"
				},
				--[[{
					ip="0.0.0.0",
					port=7654,
					protocol="inboundRawHttpStream",
					crossDomainFile="/tmp/crossdomain.xml"
				}, ]]--
				{
					ip="0.0.0.0",
					port=554,
					protocol="inboundRtsp"
				},
			},
			externalStreams = 
			{
				--[[
				{
					uri="rtsp://fms20.mediadirect.ro/live2/realitatea/realitatea",
					localStreamName="rtsp_test",
					forceTcp=true
				},
				{
					uri="rtmp://edge01.fms.dutchview.nl/botr/bunny",
					localStreamName="rtmp_test",
					swfUrl="http://www.example.com/example.swf",
					pageUrl="http://www.example.com/",
					tcUrl="rtmp://edge01.fms.dutchview.nl/botr/bunny", --this one is usually required and should have the same value as the uri
					emulateUserAgent="MAC 10,1,82,76",
				}
				{
                        		uri="rtsp://animalhousenc.dvrdns.org:554/streaming/channels/0",
                        		localStreamName="PoolSide",
                        		forceTcp=true
                		},
               		 	{
                       			 uri="rtsp://animalhousenc.dvrdns.org:556/streaming/channels/0",
                       			 localStreamName="BoneYard",
                       			 forceTcp=true
                		},
                		{
                       			 uri="rtsp://animalhousenc.dvrdns.org:557/streaming/channels/0",
                       			 localStreamName="BigPool",
                       			 forceTcp=true
                		},
               		 	{
                       			 uri="rtsp://192.168.1.186:554/mpeg4/media.amp?videocodec=h264&streamprofile=high",
                       			 localStreamName="nerd",
                       			 forceTcp=true
                		}, 
               		 	{
                       			 uri="rtsp://192.168.1.190:554/0",
                       			 localStreamName="leopard",
                       			 forceTcp=true
                		}, ]]--
			},
			validateHandshake=false,
			--enableCheckBandwidth=true,
			--[[authentication=
			{
				rtmp={
					type="adobe",
					encoderAgents=
					{
						"FMLE/3.0 (compatible; FMSc/1.0)",
						"My user agent",
					},
					usersFile="users.lua"
				},
				rtsp={
					usersFile="users.lua"
				}
			}, --]]
			mediaStorage = {
			--[[	namedStorage1={
					--this storage contains all properties with their
					--default values. The only mandatory property is
					--mediaFolder
					description="Some storage",
					mediaFolder="/Volumes/Storage/media/",
					metaFolder="/tmp/metadata",
					enableStats=false,
					clientSideBuffer=15,
					keyframeSeek=false,
					seekGranularity=0.1,
				},
				namedStorage2={
					mediaFolder="/Volumes/Storage/media/mp4",
					metaFolder="/tmp/metadata",
					seekGranularity=0.2,
					enableStats=true,
				},
				namedStorage3={
					mediaFolder="/Volumes/Storage/media/flv",
					metaFolder="/tmp/metadata",
				},
				{
					--this one doesn't have a name
					mediaFolder="/Volumes/Storage/media/mp3",
				} --]]
			},
		},
		{
			name="samplefactory",
			description="asdsadasdsa",
			protocol="dynamiclinklibrary",
			aliases=
			{
				"httpOutboundTest"
			},
			acceptors = 
			{
				{
					ip="0.0.0.0",
					port=8989,
					protocol="httpEchoProtocol"
				},
				{
					ip="0.0.0.0",
					port=8988,
					protocol="echoProtocol"
				}
			},
			validateHandshake=false,
			--default=true,
		},
		{
			name="vptests",
			description="Variant protocol tests",
			protocol="dynamiclinklibrary",
			aliases=
			{
				"vptests_alias1",
				"vptests_alias2",
				"vptests_alias3",
			},
			acceptors = 
			{
				{
					ip="0.0.0.0",
					port=1111,
					protocol="inboundHttpXmlVariant"
				}
			},
			validateHandshake=false,
			--default=true,
		},
		{
			name="admin",
			description="Application for administering",
			protocol="dynamiclinklibrary",
			aliases=
			{
				"admin_alias1",
				"admin_alias2",
				"admin_alias3",
			},
			acceptors = 
			{
				{
					ip="0.0.0.0",
					port=1112,
					protocol="inboundJsonCli",
					useLengthPadding=true
				},
			},
			validateHandshake=false,
			--default=true,
		},
		{
			name="proxypublish",
			description="Application for forwarding streams to another RTMP server",
			protocol="dynamiclinklibrary",
			acceptors =
			{
				{	
					ip="0.0.0.0",
					port=6665,
					protocol="inboundLiveFlv"
				},
			},
			abortOnConnectError=true,
			targetServers = 
			{
				--[[{
					targetUri="rtmp://x.xxxxxxx.fme.ustream.tv/ustreamVideo/xxxxxxx",
					targetStreamName="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
					localStreamName="stream1",
					emulateUserAgent="FMLE/3.0 (compatible; FMSc/1.0 http://www.rtmpd.com)"
				}]]--,
				--[[{
					targetUri="rtmp://gigi:spaima@localhost/vod",
					targetStreamType="live", -- (live, record or append)
					emulateUserAgent="My user agent",
					localStreamName="stream1",
					keepAlive=true
				},]]--
			},
			externalStreams = 
			{
				--[[{
					uri="rtsp://fms20.mediadirect.ro/live2/realitatea/realitatea",
					localStreamName="stream1",
					forceTcp=true,
					keepAlive=true
				},]]--
			},
			validateHandshake=false,
			--default=true,
		},
		{
			name="stresstest",
			description="Application for stressing a streaming server",
			protocol="dynamiclinklibrary",
			targetServer="localhost",
			targetApp="vod",
			active=false,
			--[[streams = 
			{
				"lg00","lg01","lg02","lg03","lg04","lg05","lg06","lg07","lg08",
				"lg09","lg10","lg11","lg12","lg13","lg14","lg15","lg16","lg17",
				"lg18","lg19","lg20","lg21","lg22","lg23","lg24","lg25","lg26",
				"lg27","lg28","lg29","lg30","lg31","lg32","lg33","lg34","lg35",
				"lg36","lg37","lg38","lg39","lg40","lg41","lg42","lg43","lg44",
				"lg45","lg46","lg47","lg48","lg49"
			},]]--
			streams = 
			{
				"mp4:lg.mp4"
			},
			numberOfConnections=10,
			randomAccessStreams=false
		},
		--[[{
			name="vmapp",
			description="An application demonstrating the use of virtual machines",
			protocol="dynamiclinklibrary",
			vmType="lua",
			script="flvplayback.lua",
			aliases=
			{
				"flvplayback1",
				"vod1"
			},
			acceptors=
			{
				{
					ip="0.0.0.0",
					port=6544,
					protocol="inboundTcpTs"
				}
			}
		},]]--
		--#INSERTION_MARKER# DO NOT REMOVE THIS. USED BY appscaffold SCRIPT.
	}
}

Once you have this saved (or modified yours to look like this you can go ahead and try to start the server with the following command (NOTE: you need to be in the cmake directory (rather than crtmpserver) and reference the files with partial paths……not sure why…..something to do with cmake base directory).

cd /opt/crtmpserver/builders/cmake/
./crtmpserver/crtmpserver ./crtmpserver/crtmpserver.lua

You should get output similar this this

/crtmpserver/src/crtmpserver.cpp:216 C++ RTMP Media Server (www.rtmpd.com) version 1.1_rc1 build 808 - Gladiator - (built on 2013-09-28T21:19:24.000)
/crtmpserver/src/crtmpserver.cpp:219 OS files descriptors count limits: 4096/4096
/crtmpserver/src/crtmpserver.cpp:221 Initialize I/O handlers manager: epoll without timerfd_XXXX support
/crtmpserver/src/crtmpserver.cpp:224 Configure modules
/crtmpserver/src/crtmpserver.cpp:230 Plug in the default protocol factory
/crtmpserver/src/crtmpserver.cpp:237 Configure factories
/thelib/src/configuration/module.cpp:97 Loaded factory from application samplefactory
/crtmpserver/src/crtmpserver.cpp:243 Configure acceptors
/thelib/src/netio/epoll/iohandlermanager.cpp:120 Handlers count changed: 0->1 IOHT_ACCEPTOR
/thelib/src/netio/epoll/iohandlermanager.cpp:120 Handlers count changed: 1->2 IOHT_ACCEPTOR
/thelib/src/netio/epoll/iohandlermanager.cpp:120 Handlers count changed: 2->3 IOHT_ACCEPTOR
/thelib/src/netio/epoll/iohandlermanager.cpp:120 Handlers count changed: 3->4 IOHT_ACCEPTOR
/thelib/src/netio/epoll/iohandlermanager.cpp:120 Handlers count changed: 4->5 IOHT_ACCEPTOR
/thelib/src/netio/epoll/iohandlermanager.cpp:120 Handlers count changed: 5->6 IOHT_ACCEPTOR
/thelib/src/netio/epoll/iohandlermanager.cpp:120 Handlers count changed: 6->7 IOHT_UDP_CARRIER
/thelib/src/netio/epoll/iohandlermanager.cpp:120 Handlers count changed: 7->8 IOHT_ACCEPTOR
/thelib/src/netio/epoll/iohandlermanager.cpp:120 Handlers count changed: 8->9 IOHT_ACCEPTOR
/thelib/src/netio/epoll/iohandlermanager.cpp:120 Handlers count changed: 9->10 IOHT_ACCEPTOR
/thelib/src/netio/epoll/iohandlermanager.cpp:120 Handlers count changed: 10->11 IOHT_ACCEPTOR
/thelib/src/netio/epoll/iohandlermanager.cpp:120 Handlers count changed: 11->12 IOHT_ACCEPTOR
/crtmpserver/src/crtmpserver.cpp:249 Configure instances
/crtmpserver/src/crtmpserver.cpp:255 Start I/O handlers manager: epoll without timerfd_XXXX support
/crtmpserver/src/crtmpserver.cpp:258 Configure applications
/thelib/src/configuration/module.cpp:177 Application admin instantiated
/thelib/src/configuration/module.cpp:177 Application appselector instantiated
/thelib/src/configuration/module.cpp:177 Application flvplayback instantiated
/thelib/src/netio/epoll/iohandlermanager.cpp:120 Handlers count changed: 12->13 IOHT_TIMER
/thelib/src/configuration/module.cpp:177 Application proxypublish instantiated
/thelib/src/netio/epoll/iohandlermanager.cpp:120 Handlers count changed: 13->14 IOHT_TIMER
/thelib/src/configuration/module.cpp:177 Application samplefactory instantiated
/thelib/src/configuration/module.cpp:177 Application stresstest instantiated
/thelib/src/configuration/module.cpp:177 Application vptests instantiated
/crtmpserver/src/crtmpserver.cpp:264 Install the quit signal
/crtmpserver/src/crtmpserver.cpp:275 
+-----------------------------------------------------------------------------+
|                                                                     Services|
+---+---------------+-----+-------------------------+-------------------------+
| c |      ip       | port|   protocol stack name   |     application name    |
+---+---------------+-----+-------------------------+-------------------------+
|tcp|        0.0.0.0| 1112|           inboundJsonCli|                    admin|
+---+---------------+-----+-------------------------+-------------------------+
|tcp|        0.0.0.0| 1935|              inboundRtmp|              appselector|
+---+---------------+-----+-------------------------+-------------------------+
|tcp|        0.0.0.0| 8081|             inboundRtmps|              appselector|
+---+---------------+-----+-------------------------+-------------------------+
|tcp|        0.0.0.0| 8080|             inboundRtmpt|              appselector|
+---+---------------+-----+-------------------------+-------------------------+
|tcp|        0.0.0.0| 6666|           inboundLiveFlv|              flvplayback|
+---+---------------+-----+-------------------------+-------------------------+
|tcp|        0.0.0.0| 9999|             inboundTcpTs|              flvplayback|
+---+---------------+-----+-------------------------+-------------------------+
|udp|        0.0.0.0|10000|             inboundUdpTs|              flvplayback|
+---+---------------+-----+-------------------------+-------------------------+
|tcp|        0.0.0.0|  554|              inboundRtsp|              flvplayback|
+---+---------------+-----+-------------------------+-------------------------+
|tcp|        0.0.0.0| 6665|           inboundLiveFlv|             proxypublish|
+---+---------------+-----+-------------------------+-------------------------+
|tcp|        0.0.0.0| 8989|         httpEchoProtocol|            samplefactory|
+---+---------------+-----+-------------------------+-------------------------+
|tcp|        0.0.0.0| 8988|             echoProtocol|            samplefactory|
+---+---------------+-----+-------------------------+-------------------------+
|tcp|        0.0.0.0| 1111|    inboundHttpXmlVariant|                  vptests|
+---+---------------+-----+-------------------------+-------------------------+
/crtmpserver/src/crtmpserver.cpp:276 GO! GO! GO! (2368)

So far so good……the server is up and running now. You can stop it using Ctrl-C. Lets continue…….

2) C920 install and config (v4l2), ffmpeg installation, boneCV installation from Derek Molloy’s site

Logitec C920 is a really nice camera. Bit on the expensive side, but incredibly capable as we’ll see. I came across a post from Derek Molloy where he talks about UDP streaming h.264 streams off the C920 using a beagle board. That’s when I discovered the magic of this little camera. You see, the camera can provide image data via usb just like any other camera, but it also has the built in capability of producing a 3.5 Mb/s CBR video stream encoded in h.264 in either 640×480, 1280×720 or 1920×1080. I literally jumped out of my seat when I read this and picked one up from the local Best Buy (about $100). So now to get this signal in we need some of the tools that come with v4l (video4linux) utility package. Here is how you go about it:

  • First we need to install v4l-utils, ffmpeg and git (need git to grab the code in next step)
    apt-get install v4l-utils ffmpeg git
  • Then we need to pull down some code Derek has modified (and or written) from his git repo
    cd /opt
    git clone git://github.com/derekmolloy/boneCV
    
  • Next we need to get into the boneCV directory and recompile Derek’s capture.c program
    cd /opt/boneCV
    gcc -o capture capture.c
  • Now that we have the fresh capture program maybe we should stop and let me explain. capture.c is a V4L2 video capture example, modified by Derek Molloy for the Logitech C920 camera. He’s added the -F mode for H264 capture and associated help detail, plus an option to allow capture to capture infinite number of frames. Before we continue to the next step it’s worth trying to visualize the chain we’re trying to create. Capture (capture.c) will be called to put the camera in -F mode (1080p h.264 pre-encoded 3.5Mb/s CBR stream over USB) and to continuously pass the frames to a pipe which will feed avconv (a program that comes with ffmpeg) that will not touch the video encoding of the file but will transmit it to a RTSP destination (our crtmp streaming server). Once the stream is runnning we will use JWplayer to view the RTMP stream. The reason I decided to use JWplayer is that various incarnations of VLC say they support RTMP, but their implementation is really bad. For the longest time while using VLC to view the stream (I think it was version 2.1.x and 2.2.x nightly builds) I had freezes and breakups in the stream and I thought the poor Pi was not doing it’s job. NO, it was the player, the Pi (and Beagle Board Black) worked wonderfully. So now we need to modify the streamVideoRTSP file Derek has to look like the following (might want to save the original as .bak or something).
    #!/bin/bash
    echo "Video Streaming for the Beaglebone - derekmolloy.ie"
    echo "Piping the output of capture to avconv"
    #1080P mode 
    v4l2-ctl --set-fmt-video=width=1920,height=1080,pixelformat=1
    #720P mode
    #v4l2-ctl --set-fmt-video=width=1280,height=720,pixelformat=1
    
    # Pipe the output of capture into avconv/ffmpeg
    # capture "-F"   My H264 passthrough mode
    #         "-o"   Output the video (to be passed to avconv via pipe)
    #         "-c0"  Capture 0 frames, which means infinite frames in my program
    # avconv "-i -"  Take the input from the pipe
    #        "-vcodec copy" Do not transcode the video
    
    #1080P mode
    ./capture -F -o -c0|avconv -re -i - -f alsa -ac 2 -i hw:1,0 -strict experimental -threads 0 -acodec aac -ab 64k -ac 2 -vcodec copy -f  rtsp -metadata title=teststream rtsp://127.0.01:554/live
    #720P mode
    #./capture -f -o -c0|avconv -re -i - -f alsa -ac 2 -i hw:1,0 -strict experimental -threads 0 -acodec aac -ab 64k -ac 2 -vcodec copy -f  rtsp -metadata title=teststream rtsp://127.0.01:554/live
     

3) Configuring ddclient for dynamic DNS (optional)

This is totally optional and has no effect on the final product (makes life a bit simpler). I’m just going to provide the bare minimum explanation and my config. This process is very dependant on your DNS provider (if you have one), my example config is for my provider easydns.com. Your mileage will vary :-).

  • First we need to get ddclient program installed (this is one of dynamic dns tools available in linux)
    apt-get install ddclient
  • Then we need to edit the config file located in /etc called ddclient.conf. Here is mine which is specific for easydns.com. YOU WILL HAVE TO MODIFY THIS TO SUITE YOUR DNS PROVIDER.
    
    # Configuration file for ddclient generated by debconf
    #
    # /etc/ddclient.conf
    # updates internet ip on wired
    protocol=easydns,
    # Use this is you want to register the interface ip address (ie: You're not behind a NAT or you don't care)
    use=if, if=eth0,
    # Use this is you want to register your external ip address (ie: You're behind a NAT and want to register your outside IP address not the internal 192.168.x.x one)
    #use=web, web=checkip.dyndns.com/, web-skip='IP Address' 
    server=members.easydns.com,
    login=easydnsuserid,
    password='easydnspassword',
    hostname.domain.com
    
  • If you’ve enabled two factor authentication on easyDNS (or maybe even if you have not) there is a token that you’ll need to get called “Dynamic Authentication Token”. You can grab yours under the dynamic records page by enabling “Dynamic Authentication Token” and vieing your code. I will use XXXXXXXXXXXXXXXX as my code in the following example (NOTE: server and password clauses need to be changed):
    
    # Configuration file for ddclient generated by debconf
    #
    # /etc/ddclient.conf
    # updates internet ip on wired
    protocol=easydns,
    # Use this is you want to register the interface ip address (ie: You're not behind a NAT or you don't care)
    use=if, if=eth0,
    # Use this is you want to register your external ip address (ie: You're behind a NAT and want to register your outside IP address not the internal 192.168.x.x one)
    #use=web, web=checkip.dyndns.com/, web-skip='IP Address' 
    server=api.cp.easydns.com,
    login=easydnsuserid,
    password='XXXXXXXXXXXXXXXX',
    hostname.domain.com
    
  • Once the config is there we can restart the ddclient service
    service ddclient restart
  • If you want to check/test/debug your ddclient config, first stop the daemon that’s running in the backgroud, start it from command line in forground like below
    service ddclient stop
    ddclient -daemon=0 -debug -verbose -noquiet

4) Putting it all together and creating a webpage with embedded JWplayer to view the stream

So now you need to grab JWplayer (the free version) install it (copy the jwplayer folder) into a folder on your webserver (I copied mine into a folder of my blog server). The main file here is the HTML file that has the specifications for the stream in it. You need to create this to suite your need (ie: if you have dynamic DNS use the DNS name or if you don’t use the IP address of the Pi/BeagleBoard. Your mileage will vary :-).

Screen Shot 2013-11-09 at 4.42.17 PM

The above code is an example you will need to sustitute your own data to get it to work. We need two ssh windows off the Pi (one to run the crtmpserver and the other to start capturing and feeding it via streamVideoRTSP script. So go ahead start crtmp (see above….we did this as a test in step 1) and in the other window start streamVideoRTSP script. Those two windows should look like this:

Screen Shot 2013-11-09 at 4.59.39 PM

That’s pretty much it. If you now load the html file for jwplayer and press play (assuming you’ve done everything correctly) the stream should start playing in about 4-5 seconds. The encoding delay in the entire chain is about 2-3 seconds, the quality (considering it’s a webcam feeding a $35 computer) is really good and given proper power the Pi can steam this 1080p/30 stream without a issue. Just for the fun of it I also (at the same time) tried to feed the crtmp server (on the pi) a seperate quarter rez HD stream (640×360) encoded by ffmpeg on my desktop and yep, no problems (although the Pi is on medium overclocking settings). These RTMP streams can also be very easily scaled by passing them to larger crtmp installations and/or ustream/wowza for rebroadcast. Below you’ll find a bunch of ffmpeg command line entries I used for this second stream and also a quick (optional) write up on how I got the wireless dongle from Trendnet to work and configured from CLI.

./ffmpeg -re -i /Volumes/Qmultimedia/1217209\(73\).avi -vcodec libx264  -b 500000 -s 640x360 -strict experimental -g 25 -me_method zero -acodec aac -ab 96000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb -f mpegts -metadata title=xxx udp://192.168.1.69:10000?pkt_size=1316
./ffmpeg -re -i /Volumes/Qmultimedia/1217209\(73\).avi -vcodec libx264  -b 500000 -s 640x360 -strict experimental -g 25 -me_method zero -acodec aac -ab 96000 -ar 48000 -ac 2 -f flv rtmp://192.168.1.69:1935/live/xxx
./ffmpeg -re -i /Volumes/Qmultimedia/1217209\(73\).avi -vcodec libx264  -b 500000 -s 640x360 -strict experimental -g 25 -me_method zero -acodec aac -ab 96000 -ar 48000 -ac 2 -f rtsp -metadata title=xxx rtsp://192.168.1.69:554/live

For wireless I’m using a TrendNet TEW-645UB which is directly supported under linux. Initially I used wpa_cli to get things configured and once the system was configured I massaged the files a bit. Here is a log of the whole thing:

root@picrtmp:~# lsusb
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. 
Bus 001 Device 004: ID 157e:3013 TRENDnet 
Bus 001 Device 006: ID 046d:082d Logitech, Inc. 
root@picrtmp:~# wpa_cli 
wpa_cli v1.0
Copyright (c) 2004-2012, Jouni Malinen <j@w1.fi> and contributors

This program is free software. You can distribute it and/or modify it
under the terms of the GNU General Public License version 2.

Alternatively, this software may be distributed under the terms of the
BSD license. See README and COPYING for more details.

Selected interface 'wlan0'

Interactive mode

> scan
OK
CTRL-EVENT-SCAN-RESULTS 
> scan_results
bssid / frequency / signal level / flags / ssid
7c:d1:c3:zz:yy:xx	2411	-50	[WPA2-PSK-CCMP][ESS]	Nerdlogger
7c:d1:c3:zz:yy:xx	2412	-51	[WPA2-PSK-CCMP][ESS]	MaNiAc 2Ghz
8c:7c:b5:zz:yy:xx	2437	-64	[WPA-PSK-CCMP][ESS]	PS3-3313551
> add_network
0
> set_network 0 ssid "Nerdlogger"
OK
> set_network 0 psk "supersecretpassword"
OK
> enable_network 0
OK
> add_network
1
> set_network 1 ssid "MaNiAc 2Ghz"
OK
> set_network 1 psk "supersecretpassword"
OK
> enable_network 1
OK
> save_config
OK
> quit
> 
root@picrtmp:~# iwconfig
wlan0     IEEE 802.11bgn  ESSID:"MaNiAc 2Ghz"  
          Mode:Managed  Frequency:2.412 GHz  Access Point: 7C:D1:C3:CA:0F:7A   
          Bit Rate=43.3 Mb/s   Tx-Power=20 dBm   
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:on
          Link Quality=59/70  Signal level=-51 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:1   Missed beacon:0

lo        no wireless extensions.

eth0      no wireless extensions.

root@picrtmp:~# ifconfig
eth0      Link encap:Ethernet  HWaddr b8:27:eb:37:a6:b3  
          inet addr:192.168.1.189  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:10397 errors:0 dropped:1 overruns:0 frame:0
          TX packets:5361 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:726543 (709.5 KiB)  TX bytes:918179 (896.6 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan0     Link encap:Ethernet  HWaddr 00:14:d1:cc:16:d2  
          inet addr:192.168.1.69  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1389 errors:0 dropped:41 overruns:0 frame:0
          TX packets:36 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:466517 (455.5 KiB)  TX bytes:4773 (4.6 KiB)

root@picrtmp:~# cat /etc/network/interfaces 
auto lo

iface lo inet loopback
auto eth0
iface eth0 inet dhcp

auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
	wpa-driver wext
	wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

iface default inet dhcp

iface work inet dhcp

iface home inet static
	address 192.168.1.69
	netmask 255.255.255.0
	network 192.168.1.0
	broadcast 192.168.1.255
	gateway 192.168.1.1
	dns-nameservers 192.168.1.1

root@picrtmp:~# cat /etc/wpa_supplicant/wpa_supplicant.conf 
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
	ssid="Nerdlogger"
	psk="supersecretpassword"
	id_str="work"
}

network={
	ssid="MaNiAc 2Ghz"
	psk="supersecretpassword"
	id_str="home"
}

root@picrtmp:~#