RaspberryPi

From Matt Morris Wiki
Jump to navigation Jump to search

Fixing GDBus.Error.org.freedesktop.PolicyKit1.Error.Failed

sudo nano /etc/xdg/autostart/lxpolkit.desktop

add the text 'LXDE' to the line 'NotShownIn' thus:

NotShowIn=GNOME;KDE;LXDE

Accessing Files from Mac

sudo apt-get install netatalk

Installs the appletalk protocol on the Pi. This lets you use the following (at the terminal prompt on the Mac) to connect to the Pi

open afp://192.168.0.11

Backup / Restore

SD info

  • Verified cards here: http://elinux.org/RPi_SD_cards
  • SD Card: rumours that class 10 designed for fast sequential so not necessarily best for random access
  • Sandisk class 4 16GByte has some good reviews
  • Went for "SanDisk 16GB Extreme HD Video SDHC UHS-I Card" in the end, eg top end of class 10, 12.60 GBP - see how boots compared to original

VNC

  • SSH and then Remote X Window session via VMC: http://myraspberrypiexperience.blogspot.co.uk/p/setting-up-vnc.html
    • SSH: Start Terminal and run "ssh pi@192.168.0.11"
    • VNC Server Run at bootup - script at /etc/init.d/vncboot, set up via instructions at: http://elinux.org/RPi_VNC_Server
      • Modify the file permissions so it can be executed
        • chmod 755 /etc/init.d/vncboot
      • Enable dependency based boot sequencing
        • update-rc.d /etc/init.d/vncboot defaults
      • If enabling dependency based boot sequencing was successful, it says
        • update-rc.d: using dependency based boot sequencing
    • Current VNC on boot: /usr/bin/vncserver :1 -geometry 1280x800 -depth 16 -pixelformat rgb56
    • Mac Client: VNC Viewer, normal password, address is 192.168.0.8:1

Time Lapse

Use ffmpeg, they are more secure than avconv as of Jan15, and also haven't tried to edge their rivals out of Debian packaging with dubious error messages.

encoder

ls *.jpg > stills.txt

The mencoder software was then used to create a HD (1080p) MPEG-4 video file for upload to YouTube:

$mencoder -nosound -ovc lavc -lavcopts vcodec=mpeg4:aspect=16/9:vbitrate=8000000 -vf scale=1920:1080 -o tlcam.avi -mf type=jpeg:fps=24 mf://@stills.txt

avconv

avconv -r 10 -i myimage_%04d.jpg -r 10 -vcodec libx264 -crf 20 -g 15 timelapse.mp4

The video will be the full resolution of the default image size (2592×1944). To crop the images and create a more standard 1280×720 resolution video you can use the following command :

avconv -r 10 -i timelapse_%04d.jpg -r 10 -vcodec libx264 -crf 20 -g 15 -vf crop=2592:1458,scale=1280:720 timelapse.mp4

  • The “vf” option defines a video filter. In this case two filters which crop the incoming image to 2592×1458 and then scale them to 1280×720.
  • The “r” option tells avconv to create a video with a frames per second of 10. It appears twice to prevent avconv dropping frames that it thinks are similar.
  • The “crf” option tells avconv to aim for a quality level of “20” which is a good starting point. Lowers values are better but will increase the file size.
  • The “-g” option sets the GOP value. The YouTube Advanced Encoding Settings page recommends that the GOP should be set to half the frame rate so this is set to 15.

The conversion process is very slow on the Pi compared to doing the same thing on a desktop PC. For long sequences with hundreds of frames I would recommend downloading an appropriate version of Libav on your desktop or laptop and build your MP4 files much faster!

ffmpeg

ffmpeg -r 18 -q:v 2 -start_number XXXX -i /tmp/timelapse/IMG_%d.JPG output.mp4

FFmpeg can make a sequence of JPEGs in a directory in to a movie, To make the video just use this simple one line command

ffmpeg -framerate 24 -pattern_type glob -i "*.jpg" output.mp4

I do not recommend doing this on a RPi, but this will sharpen the images and make the encoding as high quality as possible.

ffmpeg -framerate 24 -pattern_type glob -i "*.jpg" -b 10M -filter:v unsharp=5:5:1.0:5:5:0.0 -c:v libx264 -tune film output.mp4

If you plan on exporting to Youtube use this. Youtube use FFmpeg their side too, these setting will mean it wont get re-encoded again therefore keeping the video quality.

ffmpeg -framerate 24 -pattern_type glob -i "*.jpg" -filter:v unsharp=5:5:1.0:5:5:0.0 -c:v libx264 -preset slow -crf 18 -pix_fmt yuv420p output.mkv

Corrections: the change of exposure time at sunset ensures that each individual image is reasonably exposed, but when stitching them into a movie, this results in a little flicker each time the shutter time is ramped up. This can easily be adjusted for by running the following before ffmpeg:

for a in *; do echo $a;/opt/ImageMagick/bin/mogrify -auto-gamma $a;done

Projects

  • snap-pin headers: try amplifier and sound processing
    • try direct sound generation
    • try pseudo-theremin with distance sensor
  • power supply: try printer
  • crimper: try piezo leads
  • small speakers: leads with crimper

Things to do:

NAS:

On Hold:

  • Raspbmc: C4 (currently broken on encryption)
  • Raspbmc: C5 (currently broken on encryption)

DONE

Useful links:

Getting hostname setup

  • alter /etc/hosts and /etc/hostname
  • Follow these steps to get broadcast working
sudo apt-get install avahi-daemon
sudo insserv avahi-daemon //makes it automatically start

//Then create a config file: (attached my basic one)
sudo nano /etc/avahi/services/multiple.service
//There are a couple different variations of this on the web but this suits my ownCloud needs
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
        <name replace-wildcards="yes">%h</name>
        <service>
                <type>_device-info._tcp</type>
                <port>0</port>
                <txt-record>model=RackMac</txt-record>
        </service>
        <service>
                <type>_ssh._tcp</type>
                <port>22</port>
        </service>
 <service>
                <type>_http._tcp</type>
                <port>80</port>
        </service>
</service-group>

//Then restart the service 
sudo /etc/init.d/avahi-daemon restart