Friday, January 25, 2013

Broadcast Live Video in ASCII Art with Hasciicam

Broadcast Live Video in ASCII Art with Hasciicam

hasciicam-teaserIs Skype a little too modern for your taste? Hasciicam will take you back to the electronic days of yore, where you can broadcast live video to your friends â€" and even the public â€" in ASCII art.

Hasciicam is a small command-line application written in C. It was originally developed by Rastasoft as part of the libre operating system “dyne:bolic”, but you can run it on any Linux operating system as a standalone program.

Requirements

Getting Hasciicam

Many Linux repositories stock Hasciicam. If yours doesn’t, or if you’d like to build it from source, get it from the dyne.org FTP server.

Basic Usage

If you just want to see yourself in ASCII art or test your webcam, you can run Hasciicam in live mode. This is the default mode, so it doesn’t require any command-line arguments. Just run:

A window called “aa for X” will open. This is Hasciicam and AAlib in action:

hasciicam-live

Broadcast Live Video

To broadcast live video, we need a destination to send it to. Here’s where the FTP server comes in.

The first command-line switch we need to use is “-m” for “mode.” The three possible modes are live (which we used in the previous example), HTML, and text. When you’re pushing to an FTP server, you must use either HTML or text mode.

Use -m html for broadcasting video; thereâ €™s no refresh function in text mode, so all you’ll get is a static text file.

The next switch is -f to specify the FTP server and login details. It follows this format:

Finally, we need to give Hasciicam an output file with “-o“. The default is hasciicam.html, but you might want to change this to index.html to save your viewer(s) some typing.

Here’s an example I used to broadcast my video to another computer on my local area network (LAN), creating the file index.html in that user’s home directory:

hasciicam -m html -f :ruji@192.168.1.167:/ -o index.html

I also tested this method on my public website, using this format to connect to the server and save index.html in a directory called “hasciicam”:

hasciicam -m html -f :ruji@mywebhostingcompany.com:/public_html/hasciicam/ -o index.html

After I entered the command, my webcam light turned on, and Hasciicam prompted me for my FTP password:

hasciicam-ftp-terminal

In my browser, I navigated to the hasciicam directory on my website. And there I was, in glorious green characters on a black background, albeit with a lag of about ten to fifteen seconds.

hasciicam-online

The only problem besides the lag was that the image was stretched out horizon tally. Fortunately, Hasciicam lets you change the rendering options for a better picture.

Rendering Options

Hasciicam gives you a few different command-line switches for changing the appearance of the output. Enter any of these after your FTP information:

Change font size (choose a number between 1 and 4):

Change font face (this didn’t work for me):

Change refresh rate in seconds (default is 2):

Set background color (use hexadecimal format without the leading “#“):

Set foreground color:

Hasciicam also lets you adjust the contrast, gamma, and brightness. See the main page for details.

Here I changed the font size to fix the stretching problem, and I also set the colors to blue on red and the refresh rate to every second:

hasciicam -m h   tml -f :ruji@mywebhostingcompany.com:/public_html/hasciicam/ -o index.html -B FF0000 -F 0000FF -S 4 -r 1

The output looks like this:

hasciicam-blue-on-red

To stop your Hasciicam stream, just hit “Ctrl + C” in the console you ran the command in.

Note that the HTML page will remain on your server, and it will keep trying to refresh even without new data coming in. If you want to keep the page on your server but stop it from refreshing, just remove this line from the top of the file:

<meta http-equiv="refresh" content="1" />

Conclusion

While Hasciicam isn’t exactly full-featured â€" for instance, there’s no integrated audio streaming â€" you can extend this simple program yourself. A rather low-quality solution could be to set up a separate HTTP audio streaming server and embed the audio stream alongside Hasciicam’s output using iFrames (just a thought!).

What do you think of Hasciicam? Is there anything else you wish you could do with ASCII art?

No comments:

Post a Comment

//PART 2