From glc stream to Premiere Pro dv avi

Ok, I admit it, I still video edit in Windoze, using Premiere Pro. Haven’t found an alternative I trust yet (but watch this space). My big problem is that Premiere Pro is picky as to what video codec thingy it will accept but tonight I made a breakthrough with taking a glc stream (see here for a clue as to what I’m talking about) and turning it into a video I can import into Premiere’s choosy ‘bin’ of video clips so that I can edit it.

In a trusty terminal, cd to the location of your glc stream (a file with .glc on the end) and run
$ glc-play [stream file].glc -y 1 -o - | ffmpeg -i - -vcodec dvvideo -r 25 [output file].avi

This pipes the glc stream straight into ffmpeg which encodes the video with an avi wrapper (I really don’t entirely know what I’m talking about here but it works). The -r 25 option forces the output to 25 frames per second – this is the correct frame rate for DV PAL.

Note – you’d better set your glc stream to be created at the right size for DV PAL, namely 720×576, otherwise it won’t work.

Posted in Linux | Tagged , , , | Comments Off on From glc stream to Premiere Pro dv avi

Python script to read our moods into an Sqlite database

This script takes a csv file, output from the mood reporting Android app that Peter wrote us and inserts the records into a database

#! usr/bin/env python
#-*- coding:utf-8 -*-
#
# Daniel Belasco Rogers 2011 Wed 16 Feb 2011 23:40:35 CET
# An attempt to parse Peter's mood track log file
#
# Takes a user (dan or soph), path to the text file and a path to a
# database

import csv
import sys
import sqlite3
from optparse import OptionParser

def getUser(username):
    """ check whether user supplied is valid
    In future, consider making this populate from database
    """
    username = username.lower()
    userDict = {'dan': 1, 'soph': 2}
    try:
        userid = userDict[username]
    except(KeyError):
        print "user '%s' not in database" % username
        sys.exit(2)
    return int(userid), username

def updateDB(moodReader, dbpath, userid):
    """ 
    iterate through the mood reports and execute insert sql on each
    record
    """
    connect = sqlite3.connect(dbpath)
    recordnum = 0
    for row in moodReader:
        # skip header
        if row[1] == 'happiness':
            continue
        recordnum += 1
        print (row)
        try:
            connect.execute("insert into mood (created, happiness, tiredness, hopeful, stress, secure, anxiety, productive, loved, note, user) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1)", row)
        except sqlite3.IntegrityError:
            print "\n*** Message already entered - skipping ***\n"
            recordnum -=1
        connect.commit()
    return recordnum


def main():
    """ 
    
    """
    usage = "usage: %prog user (dan, soph) /path/to/csv/file.csv, /path/to/database.sqlite"
    parser = OptionParser(usage, version="1.0")
    (options, args) = parser.parse_args()
    if len(args) != 3:
        parser.error("Specify a user, csv file and a database file\n")
    userid, username = getUser(args[0])
    filename = args[1]
    dbpath = args[2]
    f = open(filename,'r')
    moodReader = csv.reader(f, skipinitialspace=True)   
    recordnum = updateDB(moodReader, dbpath, userid)
    print 'Updated %d records to database\nScript Ends sucessfully - Goodbye\n' % recordnum
    f.close()
    return

if __name__ == '__main__':
    sys.exit(main())

Posted in Android, Code, Python | Tagged , | Comments Off on Python script to read our moods into an Sqlite database

Compile New GPSBabel from source

A new version of GPSBabel – version 1.4.2 came out but it’s not yet in the Ubuntu repositories and there are no binaries on the GPSBabel
site.

I’m here to tell you that installing from the source worked pretty painlessly for me – I was surprised, a testament to the GPSBabel team – but I still felt pretty proud. Information taken from here.

This was how:

  • Make sure you have libexpat-dev, if not,
    $ sudo apt-get install expat libexpat-dev
  • You should have libusb but if not,
    $ sudo apt-get install libusb-dev
  • Download the tar ball from here
  • Extract the tar ball (right click and ‘Extract Here’)
  • Open a terminal and cd to that newly created directory (this was on my desktop, where my downloaded files go as default from Firefox)
  • type $ ./configure && make
  • after a screen-full of code, if you were successful, like me, there will be a gpsbabel binary in the current folder

Your system will still use the old gpsbabel (if you’re upgrading), until you do the following. Rename (or if you’re feeling brave, delete) the
old gpsbabel in /usr/bin like so:

  • In a terminal, cd to /usr/bin:
    $ cd /usr/bin
  • Rename the current gpsbabel:
    $ sudo mv gpsbabel gpsbabel_old
  • Move the new gpsbabel into this directory:
    $ sudo mv ~/Desktop/gpsbabel-1.4.2/gpsbabel /usr/bin/
  • If you now access the gpsbabel help with
    $ gpsbabel --help | less
    you should see ‘GPSBabel Version 1.4.2. https://www.gpsbabel.org’ at the top

Congratulations! You’ve updated to the latest GPSBabel

Posted in Bash scripting, Code, Diary, GPS, Linux, Software, Ubuntu | Tagged , | Comments Off on Compile New GPSBabel from source

Posting from Emacs

Thanks to Peter, I’m writing this post in Emacs as a test to see whether it works as I think. This is how I got it all working (a lot of this depends on the very wonderful emacs starter-kit )

  • in Emacs, M-x package-list-packages
  • move cursor down to weblogger
  • press ‘i’ to select for install
  • press ‘x’ to execute the installation
  • my install process coughed, giving me the error ‘weblogger.el:154:1:Error: Cannot open load file: xml-rpc’ but with Peter’s support through Skype, I ignored, restarted emacs and bingo, there it was in all it’s webloggy functionality

(edit from wordpress) Hmm, think I’ll need to disable fill as it gets published with carriage returns everywhere and brush up on my html href (‘=’ instead of ‘:’), but otherwise, a promising start. Tags don’t seem to work though

Posted in Diary, emacs, Software | Tagged , | Comments Off on Posting from Emacs

Remove Line Breaks in OpenOffice Writer

Something I find myself doing quite a lot these days is starting to write a text in Emacs Org-Mode which I then expect ‘normal’ people to contribute to or view. (By ‘normal’ I mean the perfectly nice but less enlightened who have been duped into sending kilobytes of markup data thanks to the Word .doc or .docx format, along with their content). Because I don’t want to frighten them with a perfectly harmless, valid and platform independent text file, especially when most OS’s throw a hissy fit if they encounter a .org suffix, I tend to paste what I’ve made into an OpenOffice file and save it as a *.doc file. This means that I’m having to lose the line breaks / carriage returns that Emacs helpfully puts into my text every 80 characters or so. This is how you do it:

  • Open OpenOffice Writer
  • Paste your text from Emacs in
  • Go to Format – AutoCorrect – AutoCorrect Options
  • Select or make sure ‘Remove blank paragraphs’ is selected
  • Click ‘OK’
  • Select all text (ctrl-A)
  • Go to Format – AutoCorrect – Apply
  • Bingo (I hope)

Note: I’m using OpenOffice 3.2 on Ubuntu 10.04 (Lucid Lynx)

Posted in Diary, Linux, Software, Ubuntu | Tagged , , | Comments Off on Remove Line Breaks in OpenOffice Writer