17. April 2011

How to store video stream from Airlive camera

Airlive OD-325HD is quite good outdoor camera with night vision. This feature is quite useful when you need to monitor shop or outdoor areas.

OD-325HD camera is able to send video stream and images via TCP/IP.

How to dump image from the camera?

Wget can do all the magic.

wget "http://192.168.1.1/image.cgi?resolution=1280x1024" \
 --user=username\
 --password=somepass

What about video stream?

In this case we will need mencoder. This tool is able to read RTSP stream and store it into the file. I was playing with parameters until I found configuration for OD-325HD.

Note for Debian users: I suggest to use version from debian-multimedia.org. You can add following line into /etc/apt/sources.list:

deb http://www.debian-multimedia.org/ stable main

You can dump stream using following command:

mencoder  -v rtsp://username:somepass@192.168.1.1:554/video.mp4 \
 -rtsp-stream-over-tcp \
 -oac copy -ovc lavc -lavcopts vcodec=mpeg4 -o dump.avi

VLC plays stored video without problem. Note: Windows Media Player has some problems with playing this kind of data.

I found a lot of useful information at Covex page.

9. April 2011

UNetbootin – quick way how to create bootable USB

Imagine situation: Boot procedure on Linux server is broken. You have SystemRescueCD, but CD-ROM is not working. You have notebook with Windows and USB key.

How to fix that server?

We can use USB key! :-)

It’s quite tricky to create bootable Linux key from Windows. It requires several steps… It’s hard.

No, it’s quite easy! Just download simple tool UNetbootin and create bootable USB in few steps.

UNetbootin provides several Linux distributions. My choice was ISO image of Debian Live, because it’s quite small and it has support for XFS and other useful stuff.

Note: SystemRescueCD 2.0 ISO is not booting correctly.

7. March 2011

Spaghetti, lasagna and raviolli code

Code smells or anti-patterns are a common classification of source code quality. There is also classification based on food which you can find on Wikipedia.

Spaghetti code

Spaghetti code is a pejorative term for source code that has a complex and tangled control structure, especially one using many GOTOs, exceptions, threads, or other “unstructured” branching constructs. It is named such because program flow tends to look like a bowl of spaghetti, i.e. twisted and tangled. Spaghetti code can be caused by several factors, including inexperienced programmers and a complex program which has been continuously modified over a long life cycle. Structured programming greatly decreased the incidence of spaghetti code.

Ravioli code

Ravioli code is a type of computer program structure, characterized by a number of small and (ideally) loosely-coupled software components. The term is in comparison with spaghetti code, comparing program structure to pasta; with ravioli (small pasta pouches containing cheese, meat, or vegetables) being analogous to objects (which ideally are encapsulated modules consisting of both code and data).

Lasagna code

Lasagna code is a type of program structure, characterized by several well-defined and separable layers, where each layer of code accesses services in the layers below through well-defined interfaces. The term is in comparison with spaghetti code, comparing program structure to pasta.

Spaghetti with meatballs

The term “spaghetti with meatballs” is a pejorative term used in computer science to describe loosely constructed object-oriented programming (OOP) that remains dependent on procedural code. It may be the result of a system whose development has transitioned over a long life-cycle, language constraints, micro-optimization theatre, or a lack of coherent coding standards.

Do you know about other interesting source code classification?

1. February 2011

Linux – X.org – SiS driver configuration

These days whenever you are buying new hardware, you check compatibility – whether there are drivers and how good are they. So i.e. when selecting graphic card, you typically end up with Intel, NVIDIA or ATI. But from time to time it simply happens and you end up with something like those cards from Silicon Integrated Systems.

I’ve been installing Debian on Acer Aspire 3002LMi and everything went pretty good, but then I needed to send video only to external monitor.

Well, “Xorg -configure” was firs step. It filled xorg.conf with “working” configuration… at least it wrote there possible options. Bool-ones was pretty obvious. So I enabled shared frame-buffer. And than started fun. Metamodes… Ok, I probably needed to somehow set it, but how? I don’t think that “string” is helpful enough… So googling started. To make long story short I wasn’t able to set it up. If video was sent to both outputs at their proper resolution (LCD interpolation sux), the system became unstable – freezing from time to time totally (this behavior was observed with other OS (i.e. Redmond) too). And then I found it. Thomas Winischhofer have not only comprehensive documentation for Linux sis driver, but also great tool The SiS Display Control Panel (sisctrl) that can help you figure out which combination of settings you need. Nice GUI, it even shows you part of xorg.conf you need to modify to make your changes permanent. It can be found here: www.winischhofer.net

Debian package was probably provided once, but it doesn’t work now. It’s shame that it is not it official Debian packages. Compiling from sources will work (after installing half a billion dev-packages). ;-)

And how did I ended? Well, it was “trivial”:

Section "Device"
        Option     "ForceCRT1Type" "VGA
        Option     "ForceCRT2Type" "NONE"
        Option     "EnableSiSCtrl"
        Option     "MergedFBAuto"
        Option     "MetaModes" "1280x1024,1024x768;1280x1024+1024x768"
        Identifier  "Card0"
        Driver      "sis"
        VendorName  "Silicon Integrated Systems [SiS]"
        BoardName   "661/741/760 PCI/AGP or 662/761Gx PCIE VGA Display Adapter"
        BusID       "PCI:1:0:0"
EndSection

Author: Lordrat

30. January 2011

Developer’s problem: Windows 7 – apostrophe does not work

I found something strange. New default installation of Windows 7 had quite weird behavior of keyboard. Apostrophe, quotation mark, tilde didn’t work properly. I had to press apostrophe and then space bar to write single apostrophe.

The reason is that keyboard layout United States – International treats those keys as special. Here is quote from Microsoft support web page:

When you press the APOSTROPHE ( ‘ ) key, QUOTATION MARK ( ” ) key, ACCENT GRAVE ( ` ) key, TILDE ( ~ ) key, or ACCENT CIRCUMFLEX,. also called the CARET key, ( ^ ) key, nothing is displayed on the screen until you press a second key:

  • If you press one of the letters designated as eligible to receive an accent mark, the accented version of the letter appears.
  • If you press the key of a character that is not eligible to receive an accent mark, two separate characters appear.
  • If you press the space bar, the symbol (apostrophe, quotation mark, accent grave, tilde, accent circumflex or caret) is displayed by itself.

The following table shows the keyboard combinations that you can use to create the desired character.

Solution for developers and sys-admins is quite easy. Change keyboard layout from United States-International to something different. E.g. US.