April 18, 2009

Sofar and Roswell

Roswell was a place where an UFO crashed at 1947. Then the US government covered it up with a story of a crashed weather balloon. The X-files was a TV series based on this urban legend that then grow out of proportion. The series is very enjoyable and interesting to watch. The ”factual” story behind Roswell is quite as amazing, as told by a brilliant physicist and Berkeley professor Richard A. Muller. The Berkeley university has made a wonderful policy of uploading complete courses online available under a Creative Commons license! I love especially the Muller lectures, some of which are also available on YouTube. He makes each lecture very interesting and educational and can explain the physics in an easily understandable way. He doesn't go into the deep mathematics, but rather explains qualitative facts of nature and makes all subjects connect to real life. The Sofar bomb, actually, is a mind-blower. This item was used in WW2 as an SOS device for the pilots who flew over the Pacific Ocean. They threw an hollow sphere into the ocean and the navy could approximate their location and come to rescue. Those who have seen the Hunt for Red October know about the sound channel. In this channel the sound waves bend and reach high ranges because the channel reduces the scattering. The same phenomenon appears also in the atmosphere. This is what the Roswell weather balloon was measuring. Cold war signals from USSR. So when the balloon crashed, the ”flying discs” they had collected were in fact circular microphones. What was the saucer then?

April 2, 2009

Streaming from webcam

A little while ago I purchased a cheap webcam: Logitech QuickCam E3500. It works in Linux with the in-kernel 'uvcvideo' driver (plug-and-play) and I was interested to tinker with live video stream. It is very simple to view (a) or record (b) a video stream;
(a)  mplayer tv://
 (b)  mencoder -quiet tv:// -tv noaudio -ovc lavc -o "webcam-$(date "+%Y%m%d %H:%M").avi"
Streaming live video to the internet is a bit more complicated. At first I wanted to use FlowPlayer, a neat Flash program that has elaborate JavaScript controls, to view the stream using RTMP stream, which is a proprietary protocol. Setting up a RTMP server on the other hand seemed to be impossoble to setup in the time that I was going to invest. There seemed to be only few options; the Apple Darwin Streaming Server and Red5. In short, Darwin did not compile and Red5 was way too much work to configure. Away with RTMP - behold, VLC to the rescue!
vlc -I dummy --no-audio --no-sout-audio v4l2:///dev/video0:width=320:height=240 \
    --sout='#transcode{venc=ffmpeg,vcodec=x264,vb=256,vt=128}:std{access=mmsh,mux=asfh,dst=:8080/stream.asf}'
MMS, WTF?! A deprecated proprietary protocol and ASF container! Oh well, this was the first (and worst) simple streaming method I came across, and thought it would be worth a try. This seems to be a popular way of doing HTML embedded video. My internet connection is slow so I opted for the x264 codec, which by the way, is not supported by IE or WMP, which kind of cancels out the theoretical advantage of MMS that is works on the regular Windows user. With Firefox + VLC Mozilla plugin this seems to actually work. IE users can display the stream in VLC.
<OBJECT ID="MediaPlayer" WIDTH="640" HEIGHT="480"
    CLASSID="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95"
    STANDBY="Loading Windows Media Player components..."
    TYPE="application/x-oleobject"
    CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112">
    <PARAM name="autoStart" value="True">
    <PARAM name='showControls' value="False">
    <PARAM name="filename" value="mms://:8080/stream.asf">
    <EMBED TYPE="application/x-mplayer2"
        SRC="mmsh://:8080/stream.asf"
        NAME="MediaPlayer"
        WIDTH=640
        HEIGHT=480>
    </EMBED>
  </OBJECT>