Activity › Forums › Adobe After Effects › Video to ASCII effect
-
Video to ASCII effect
Posted by Justin Porter on October 22, 2007 at 11:15 pmSo I need to convert a video to ASCII art. I found this brief tutorial:
https://www.asciipr0n.com/4096/ascii-aex/ascii.html
However, when he says
“create an array of ascii characters in after effects. Now you map the darkest parts of the image to characters like . , : and you map the brightest parts of the image to characters like 3 8 #”
I get the basic concept of what he’s saying but I have no idea how I would execute this in After Effects. Can someone help me figure out how to accomplish this? Thanks.
Kevin Camp replied 18 years, 6 months ago 3 Members · 12 Replies -
12 Replies
-
Kevin Camp
October 23, 2007 at 5:20 pmi came up with this to paste in the source text property of a text layer:
asciiArray = [” “,”a”,”b”,”c”,”d”,”e”,”f”,”g”,”h”,”i”,”j”]; // enter characters to range from light to dark values
numCharacters = 10; // enter the total number of ascii characters entered in the array above
imageMap = thisComp.layer(“Source Image”).sampleImage([position[0], position[1]], [1, 1]);
a = Math.round(linear(imageMap[0], 0, numCharacters));
asciiArray[a]you will need cs3 (the sampleImage function is new). you will need to name you source image ‘Source Image’. if the image is color, you will need to apply and effect to make it grayscale or apply the channel combiner effect to the ‘source image’ set the ‘from’ value to ‘rgb to yuv’ (the later should be slightly better). you will also probably want to set the text layer to use a monospaced font.
for the variable asciiArray, you will need to enter the ascii characters that you want to use as values (each will need to be in quotes). for the numCharacters variable, you will need to enter the total number of ascii characters you entered in asciiArray.
the expression will create one ascii character based on the value of the image it is positioned over (if you were to drag the text layer over the source image it will change). you will need to duplicate the text layer and position into a grid.
the problem right now is that most expression that place layers in to grids need layer height and width values, and text layers only return the comp values… so they don’t work here. i’m trying to figure out how to precomp the text layer to get hieght and with values, but still get the array data to change in the precomps individually…. or some other way to get the values into grid (which may be easier).
Kevin Camp
Designer – KCPQ, KMYQ & KRCW -
Justin Porter
October 23, 2007 at 5:36 pmwow, thanks a lot Kevin, that’s really helpful. I’ll try to implement it a little later on and I’ll let you know how it works out.
Justin
-
Kevin Camp
October 23, 2007 at 7:08 pmthis seems to work…. just paste this into the position expression field for a text layer that has the ascii character expression in the expression field. then duplicate away and they should align them selves in a grid:
try{
L = thisComp.layer(“Grid Spacing”).effect(“Columns”)(“Slider”);
exists = true;
}catch (err){
exists = false;
}
if (exists){
rows = thisComp.layer(“Grid Spacing”).effect(“Rows”)(“Slider”);
cols = thisComp.layer(“Grid Spacing”).effect(“Columns”)(“Slider”);
}else{
rows = 10;
cols = 10;
}
xOffset = (thisComp.width / rows);
yOffset = (thisComp.height / cols);
x = xOffset * (((index – 1) % rows) + .5);
y = yOffset * (Math.round(((index – 1) / rows) + .5) – .5);
[x,y]by default the grid spacing is 10 by 10 (you can enter other values for rows & cols).
but there is a better way to set the grid….
the code a the top of the expression is test for a null (or layer) named ‘Grid Spacing’ with a slider control. if you add a null and name it ‘Grid Spacing’ and add 2 slider control effects and set there value to anything but zero (zero will return an error). then name the first ‘Rows’ and the second ‘Columns’.
now the expression will automaticly use the slider controls to set the gid spacing, so adjustments to the grid can be made after creating many duplicates of the text layer.
Kevin Camp
Designer – KCPQ, KMYQ & KRCW -
Justin Porter
October 23, 2007 at 10:45 pmHey Kevin, thanks again for all your work on this. I tried doing it through this method, the problem is that it takes around 2000 of these single character layers to properly fill my work area. After Effects crashes around 1200 or so.
I also found this other technique:
It uses the expression:
target = thisComp.layer(“layerToSample.mov”);
samples = new Array();var spacing = 10;
var w = target.width / spacing ;
var layerOrder = 1;
var h = 10 * layerOrder;letters = ” .,:!-+=;iot76x0s&8%#@$”;
for(x= 0; x < w; x++){ samples[x] = target.sampleImage([x* spacing ,h],[spacing , spacing], false, time); } var string = ''; for(z = 0; z < samples.length; z++){ var y = Math.round((0.299 * samples[z][0] + 0.587 * samples[z][1] + 0.114* samples[z][2]) * 100)/ 4; string = string + letters.substring(y,y + 1); I applied this to the text field and it gives me an error: " Class "Layer" has no property or Method named "Target" " on line 5. I'm really new to After Effects scripting, so I don't know why it's giving me that error. But I think this one is set up to replicate the whole grid rather than just a single character.
-
Justin Porter
October 23, 2007 at 10:51 pmOk, I figured that out. I had left out the “target =” right at the start.
So now the problem is this creates a line of text that spans the video, but it’s only a single line. I tried duplicating it and moving it, but the line of text does not seem to change based on where it’s positioned.
Again, I’m a little new to AFX scripting so I’m having trouble picking out what the problem is.
-
Kevin Camp
October 24, 2007 at 7:17 pmi don’t have as much time to play today… i looked at the link you provided. it may be that the expression needs to be used in a java script… he mentions something about looping through each line.
i’m getting better with expressions, but i don’t know much about java script. you may want to throw this on the ae expressions forum. there are many more knowlegeable expression/script writers there.
Kevin Camp
Designer – KCPQ, KMYQ & KRCW -
Justin Porter
October 25, 2007 at 12:40 amThanks again for your Help Kevin, I’ll post this quagmire in the scripting forum and I’ll post back here as soon as I’ve worked out a solution.
Justin
-
Kevin Camp
October 25, 2007 at 4:16 pmyou may also be able to do this by dividing you footage into quarters…
create a comp that is half the height and width of the final output, bring your footage in and position so that you see only one quarter (say the top-left quarter). then run through the text-expression and duplication process. to fill the screen.
now duplicate that comp 3 times in the project window open each and position the footage so that each comp covers a different quarter of the image.
now each comp should only have about 500 characters. you may need to render each out separately, then combine the renders into a single full size comp.
Kevin Camp
Designer – KCPQ, KMYQ & KRCW -
Elena Ho
October 29, 2007 at 3:34 amHey Moldyboot
Hope I’m not too late in replying but I’ve actually had to do a job a few months ago that sounds pretty similar to what you are doing.
It was copy based (based on famous quotes by famous people and so the famous people are made of alphabets). I was lucky to stumble upon some cool free presets by Harry Frank from aefreemart.com (https://aefreemart.com/2007/04/14/my-favorite-particular-things/)
With the halftone preset, I changed it to alphabets and had to play around with some of the settings. I have a low-res mpeg here (https://e-xperiments.com/Particles01.mpg)
So with the particles (custom), I created a pre-comp of alphabets A-Z (1 frame/alphabet). With some tweaks here and there Particular works out what goes where.
One things however with fine-lined alphabets on a broadcast monitor is that it will flicker crazily. So I applied a little box blur, motion blur and rendered in fields and it worked.
Good luck!!
Reply to this Discussion! Login or Sign Up