This article is a brief tutorial in how to make your own ascii internet TV station. I say brief, its pretty simple - that's why its brief.

The inspiration for such an article comes from having a telnet link posted in a channel to a server which was showing a World Cup game live via ascii and sockets. I pasted this around to a couple other people and some folk didn't understand how it worked, so I wanted to share some knowledge.

Incase some of you aren't following me, the link I was shown was

14:05 <+JonathanD> telnet ascii-wm.net 2006 14:05 <+JonathanD> watch teh world cup, in ascii 14:05 <+JonathanD> someone topic that 14:09 <+linkd> thats pretty leet Incidently this server is still up and running (checked on 2008-01-31) so you can go and watch this archived match for yourself!

I'm sure everyone has seen picture to ascii converters before. There are certain programs which will take an image in and approximate it in ascii. One program which does is the aalib library. And thats what I'll be using in this tutorial.

Argentinien - Niederlande                                                    0:0
,o%%%$$$$%%%Oo:::;O%%%%%%%%o,:oo:                            .:oooooooooooooooo:
.:o%%%$$$$$mnoPoRmmy$$%%%%%Oo,::.  .       ..    .....,.wY; , ::;:::w;o###ooooo:
oOOOOOOR%;;R;,,O,R%O;RROOOOOOoo'...,.. ..'oooooooooooooooooooooooooooooooooooooo
YYYYYYYYYYYYYYYYYYYYYYYYYYYYY^  ... .. .   ^YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
YYYYYYYYYYYYYYYYYYYYYYoYYPPYY.      ,:::.,..::::oYYYP^Yo'''YPPYYoo::::::::::::::
,:::::::::::::::::::::::::::. :::::o:':':::::::::::::::::::::,:::::::::::::::::,
,:::::::::::::::::::::::::::. ,o::oooooooo::::::::::::::,:::::::::::::::::::::::
:::::::::::::::::::::::::;;,voo::::o::o:::::::::::::::::::::::::::::::::::::::::
,::::::::::::::::::::;OovOvv%%oo::::::::::::::::::::::::::::::::::,:::::::::::::
,:::::::::::::::::;Yn.###$%%$$%%;;,:,;;%%;;::::::::::::::,:::::,::::,::::::.,::;
,:::::::::::::::::#:P.######$$#$RR$yy#R%%$%$:::::::::::::::::::::::::::;vvo:,:'%
,::::::::::::::::y#uv#P###$y$###%%%#;R%%$##$::::::::::::::::::::'   'Yo:oYOo'..o
,::::::::::::::::###$######%OP##R%%%##$%%##%::::::::::::::::::::      ::,::, ,::
,::::::::::::::::R##$##"###ooo%m#oOO##$OO$OO..,,:,,....,,:::::::::::::::::.  .,,
,::::::::::::::#####R"###RoO$:$%,OO###%O%%O:::, ..........::::::::::::::::::::,.
.,:::::::::::::#####myRRRoOO$%$#%O%$##%%OOo:::::oooo::,....,:::::::::::::::::::.
.,,::::::::::::RPOYooooo;;O$$$#oOO###%O%%OOoo;,,:'oo:::o:..::::::::::::::::::::
..,:::::::::::::oyo:ooooooO##ROOO%###YO#OoOooOO:'.:oo::ooo:::::::::::::::::::::
Argentienien after foul at Ayala. Still no danger for of Holland gate.

Can't see the picture? Step further back. It's hard to see when it's a static image Lets check off what we'll need for this:

  • A server or computer with an internet connection
  • A copy of mplayer with aalib support
  • A copy of netcat
  • Any video mplayer can play

For this tutorial I will be using a fictional server called ascii.nullnetwork.net and episode 3 of Pure Pwnage will be what I'm broadcasting.

There are two ways to go about setting up your server, the first is to transcode and steam at the same time.

~$ nc -vvlp 5050 -c 'mplayer -vo aa Pure_Pwnage_103.avi'
listening on [any] 5050 ...

The second (and my preferred method) is to make 'encodings' of any media you wish you broadcast. An ascii encoding can be made by a simple command:

~$ mplayer -vo aa Pure_Pwnage_103.avi > purepwnage.asc
Linux RTC init error in ioctl (rtc_irqp_set 1024): Permission denied
VO: [aa] cannot open /dev/vcsa06 for writing,so we'll not use linux driver
~$

To then set up the server I use netcat

~$ nc -vvlp 5050 < purepwnage.asc
listening on [any] 5050 ...

Simple!

The latter method will use more diskspace but will save on processing power.

To connect to view the stream you simply telnet or netcat in to the server.

~$ telnet ascii.nullnetwork.net 5050

Remember to make sure port 5050 is accessible though! Or you'll be hitting a brick wall wondering why it isn't working.

So how does all this work? Well, to explain how this works you will need to know that with mplayer you can specify output drivers using the -vo switch. The output driver that mplayer will recognise to use aalib is aa. So the arguments we pass to mplayer are -vo aa then the video file. Other output drivers include sdl, svga, x11, vesa and so on (see man page for more information). Using -vo aa will prompt mplayer to convert the video to ascii as it outputs. Now in the first method where we save an encoding, we are simply taking whatever mplayer outputs and redirecting it to a file. So thats how we generate our image.

To send it over a connection however we need to set up a small server to send it to people who connect, we accomplish this with netcat. We give netcat a few important instructions. The first set of switchs (-vv) are purely personal preference and cause netcat to be uber verbose. We also tell netcat to list on port 5050 by providing the -lp 5050 arguments. You may use any port you like but I choose 5050 because 5050 is hexadecimal for the ascii string "PP" (aka Pure pwnage). In the first method we simply then pipe a file into netcat to output. However the in second method the finial switch we provide runs the arguement when someone connects, so our netcat will run mplayer -vo aa Pure_Pwnage_103.avi and send the output through the socket.

You can do this with any video that mplayer can play. You however will lose your audio stream as neither telnet or netcat processes audio, and mplayer doesn't output the audio data when you pipe it like I did.

In the World Cup server they got a live feed, I assume by use of a TV Card or such, which I'm told (and implied by the man page) that mplayer can also handle. However I don't own a TV Card so I don't exactly know how to do that, but if you do know, let me know!

Have fun kids

Adapted from my nulldigital.net post dated 21st, June, 2006