Thursday, December 12, 2013

Bringing your contacts to a Nokia 7110

I  just needed a new phone and decided to go for cool solution: Nokia 7110 (v4.84).
I got one including serial data cable + dock and the only thing missing was: how do I get my contacts on the phone without typing?

The answer was quite simply: export your address book as vCard and send it to the phone via gnokii on an Ubuntu.

  1. Get your address book
    Export it somehow: I tried Evolution as well as GMail web-interface (both work).
  2. Get a serial port
    Setting up the serial port on my Lenovo X60 was not straight forward, but now it works...
    Really depends on your hardware
  3. Connect to phone
    Use minicom and check if the phone replies to AT commands
  4. Configure gnokii
    [global]
    port = /dev/ttyS0
    model = 7110
    connection = serial
    use_locking = yes
    serial_baudrate = 9600
  5. Use gnokii to read/write your address book
    gnokii --deletephonebook ME 1 200
    gnokii --writephonebook -o --vcard < addressbook.vcf


The Nokia 7110 has a bug: the vCard-parser is broken...
So, I needed to fix my addressbook: basically remove all not needed data (emails, addresses, birthdays etc.). I implemented a small python-script using vObject.
It reads from stdin and writes to stdout: cat addressbook.vcf | python script.py

#!/usr/bin/python
#encoding=UTF-8

import vobject
import sys
import inspect

#Remove entries except in list for one vcard.
def vcard3_remove_all_entries_except(vcard):
    allowedEntries = {'version', 'fn', 'tel', 'categories'}
    entries_dict = vcard.contents
    for key in entries_dict.keys():
        if key not in allowedEntries:
            del entries_dict[key]

importedVCards = vobject.readComponents("".join(sys.stdin.readlines()))
try:
    while (True):
        vcard = importedVCards.next()
        vcard3_remove_all_entries_except(vcard)

        vcard.add('n');
        try:
#            vcard.prettyPrint()
            print(vcard.serialize()),
        except Exception as e:
            print(e)
            
except StopIteration:
    None
Sync with style:
cat contacts.vcf | python import.py | gnokii --writephonebook -o --vcard

And a tutorial to clean the Nokia 7110 can be found here.

Tuesday, December 3, 2013

Transcode MKV (h264) with multiple audio streams to MP4 (AAC)

Transcoding MKV containers using avconv to MP4, so that the files can be processed with Adobe Premiere. The following command copies the video stream (should already be in h264)  and convert all audio streams to AAC. All audio streams are sampled to 6 channels (even if the source is only stereo).

avconv -i INPUT.mkv -c:v copy -map 0:0 -c:a aac -map 0:1 -map 0:2 -ab 448k -ac 6 OUTPUT.mp4

The example is for 2 audio streams; just add more -map commands as needed.