CodeWalrus

Development => PC, Mac & Vintage Computers => Topic started by: Jarren Long on September 14, 2017, 05:36:11 PM

Title: ASCII Video Generator [UCC2]
Post by: Jarren Long on September 14, 2017, 05:36:11 PM
Just a placeholder for my [UCC2] project, ASCII video generator! Well maybe, seems like a hell of an undertaking...we'll see if this ends up working.
Title: Re: ASCII Video Generator
Post by: _iPhoenix_ on September 14, 2017, 07:13:46 PM
This could be really cool if it works out!
Title: Re: ASCII Video Generator [UCC2]
Post by: c4ooo on September 14, 2017, 07:43:44 PM
So this is a VGA signal generator right? Do you plan to use TTL logic or microcontrollers? :D
Title: Re: ASCII Video Generator
Post by: Jarren Long on September 14, 2017, 08:29:39 PM
Heh, I'm not gonna get that crazy :P I'm thinking an AVI->ASCII video encoder. Well, I'm not thinking it, I'm already half way done with a crude proof-of-concept.
Title: Re: ASCII Video Generator [UCC2]
Post by: xMarminq_ on September 14, 2017, 09:20:18 PM
What's the platform?
Title: Re: ASCII Video Generator [UCC2]
Post by: Jarren Long on September 14, 2017, 10:07:15 PM
Windows, as a C#.NET library+app. Maybe Linux/Mac too if I start feeling froggy. MAYBE even Android/iOS, but that's probably pushing it.
Title: Re: ASCII Video Generator
Post by: _iPhoenix_ on September 14, 2017, 11:03:31 PM
You could do a gif->ascii generator, it might be easier, as there is somewhat of a time crunch.

I'm pretty sure converting AVI->GIF->ascii will be much easier, but I have literally no idea.
Title: Re: ASCII Video Generator [UCC2]
Post by: Jarren Long on September 14, 2017, 11:21:29 PM
Quick snapshot at where I'm leaving off at for today attached (almost time to go see Gabriel Iglasias!!!) Long story short, I was bored at work today, so I've gone from 0 to I can read in a bitmap, crunch the heck out of it, and spit out a B&W ASCII image AND text representation of it. Next steps for me are to do some color sampling on the original image, so I can set the foreground/background colors on the ASCII image, then convert those colors to 8-bit goodness. After that, it's just a matter of looping through the frames of an AVI to grab each one out as a bitmap, passing them through my library, and then stitching them back together on the other side.

And optimizing. Lots of optimizing. So much optimizing to do.  :banghead: :banghead: :banghead:
Title: Re: ASCII Video Generator
Post by: _iPhoenix_ on September 15, 2017, 11:34:27 AM
This already makes my job hard. Crud.
Title: Re: ASCII Video Generator [UCC2]
Post by: Jarren Long on September 15, 2017, 05:24:50 PM
Update: Got my coloring working! Now spitting out crud in one of 5 different color modes:
- No Color: Does no color sampling, just uses the default colors from the input bitmap font
- Original: Uses colors sampled directly from the source image
- 8-bit: Samples colors from the original image, then converts to 8-bit palette
- 15-bit: Samples colors from the original image, then converts to 15-bit palette
- 16-bit: Samples colors from the original image, then converts to 15-bit palette

It's rough, and slow, but I think I'm on to something.
Title: Re: ASCII Video Generator [UCC2]
Post by: c4ooo on September 15, 2017, 07:48:35 PM
Ohh i misunderstood, i though you where making a VGA text-mode video signal generator.
Title: Re: ASCII Video Generator
Post by: _iPhoenix_ on September 15, 2017, 07:52:17 PM
"Now spitting out crud in 5 different color modes!"

Priceless.
Title: Re: ASCII Video Generator [UCC2]
Post by: Jarren Long on September 15, 2017, 08:10:31 PM
First video conversion test complete! (1 second clip, AVI was converted to MP4 for size). Used a 1Mb clip from the movie "Big Buck Bunny" (http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4) as an input with 8-bit color downcoding and a quality setting of 60. Did it take forever to convert? Yep. Ugly. YEP. Did it work? Yep.

Video is too large to attach, stuffed it on my website. You can watch/download it at https://www.booksnbytes.net/AsciiVidTest-8bit-q60.mp4
Title: Re: ASCII Video Generator
Post by: _iPhoenix_ on September 15, 2017, 08:14:45 PM
What's really cool is that, if you play it on your phone, and hold it an arm's length away from your face, they look almost identical.

Also, can we see just an ascii art version (no color, and using only chars specified by the user, for added usability)?
That could be interesting, and would probably take less time.

Edit: ASCII also sucks because it forces everything to be shorter/taller, and it's expecially noticeable in that starwars sunset picture.
Title: Re: ASCII Video Generator [UCC2]
Post by: Jarren Long on September 15, 2017, 08:44:20 PM
No Color Version, same quality setting: https://www.booksnbytes.net/AsciiVidTest-NoColor-q60.mp4

Right now, I have the visible character set defined to cover the printable characters for the basic ASCII set (Hex 0x00-0x7F), so 69 printable characters, but that could definitely be slimmed down to just a handful of characters, which would speed up the number crunching quite a bit.

I did build my ASCII font kinda goofy, which is causing some scaling issues with the converted frames. Somehow I ended up with 10x16 pixel characters, which gives the whole shebang a weird aspect ratio. Definitely gonna need to fix that.

**EDIT**
Also, I do need to figure out something for filling in cells that don't have any edges detected, looks kinda lame just putting a space in there.
Title: Re: ASCII Video Generator
Post by: _iPhoenix_ on September 15, 2017, 08:54:23 PM
Ahh so it just filled it all with char DB.

That's why I though a custom palette could be cool;)
Title: Re: ASCII Video Generator [UCC2]
Post by: Jarren Long on September 15, 2017, 09:05:55 PM
More or less. Here's the font I threw together for testing, minus the char->bitmap definitions. Wouldn't be too hard to +/- characters, or change colors once I can bust the charmaps out of the code and dump them into a config file.
Title: Re: ASCII Video Generator [UCC2]
Post by: Jarren Long on September 28, 2017, 03:30:48 PM
Latest Updates (not many):

* Bunch of memory optimizations, now doing some of the processing in parallel, so I got a nice speed boost (ballpark of 7-8x faster) and memory reduction (about 70% less memory) in the image conversion process. Video conversion now only takes about a minute for every second of video to process at higher quality settings with coloring enabled. Only a minute :/
* Fonts are now XML-file configurable; characters used for output can be added/removed at will, and the font bitmap can be changed too. I have three fonts right now, all based on the same bitmaps
- Full set: 69 possible output characters (all printable characters from ASCII 1-128) - Slowest, best results
- Only Symbols: Full set, minus all letters/numbers - Middle ground for speed vs. accuracy
- Two character Set: It's either a # or a space - Fastest, edge resolution leaves a bit to be desired
* Added a command line program that can be used to call the API. Takes an input image, some flags, and spits out the result to a destination file
* Now have a "rescale" option, lets the output image be scaled back to the same size as the input image to fix some of the distortion problems (Console app only right now, need to add a checkbox to the WinForms test app to toggle it)
* With exception to the code snippets that handle the FFMPEG/AVI formats, everything is written in pure C#, should be easy to port to other .NET platforms now

B&W Video Test: https://www.booksnbytes.net/test-out-noColor.mp4
Color Video Test: https://www.booksnbytes.net/test-out-q80-e30-c8.mp4
Title: Re: ASCII Video Generator
Post by: ordelore on October 01, 2017, 03:16:54 AM
This is looking really neat! i'm particularly impressed with how accurate the color ascii looks. It kinda reminds me of late 90s PC game illustration.
Title: Re: ASCII Video Generator
Post by: _iPhoenix_ on October 01, 2017, 03:12:47 PM
Quote from: ordelore on October 01, 2017, 03:16:54 AM
This is looking really neat! i'm particularly impressed with how accurate the color ascii looks. It kinda reminds me of late 90s PC game illustration.

I agree; it looks very beautifully crappy in a very awesome nostalgic way.
Title: Re: ASCII Video Generator [UCC2]
Post by: RalphDSpam on October 07, 2017, 04:22:12 AM
Looks neat!

Just out of curiosity, how good is this as a "compression algorithm"?
If you put each frame of raw text in a file and zipped it, how would it compare to the original video?
Title: Re: ASCII Video Generator
Post by: Dream of Omnimaga on October 08, 2017, 10:32:53 PM
Looks awesome given the limitations!
Title: Re: ASCII Video Generator
Post by: _iPhoenix_ on October 13, 2017, 11:11:30 AM
Quote from: xlibman on October 08, 2017, 10:32:53 PM
Looks awesome given the limitations!

No kidding!

Both entries (I'm making an [un]safe assumption that there are only two) are exceptional, and it will be quite the challenge to judge them.

I'll probably enlist the help of some IRL friends to help me with the judging, and will post their results on the official unofficial thread.
Title: Re: ASCII Video Generator
Post by: Jarren Long on October 18, 2017, 08:30:39 PM
Now that the contest is over, I've released the source code for this atrocity, see https://github.com/JarrenLong/bmp2ascii, in case anyone is interested in this big ball of wibbly-wobbly, timey-wimey trainwreck, have at it! Hoping @Juju will be letting his out into the wild sometime soon too, I'm definitely curious to see that magical goodness in action :)
Title: Re: ASCII Video Generator
Post by: Yuki on October 18, 2017, 08:32:44 PM
Quote from: Jarren Long on October 18, 2017, 08:30:39 PM
Hoping @Juju will be letting his out into the wild sometime soon too, I'm definitely curious to see that magical goodness in action :)
I'm going to update my topic, you won't believe line 12! #clickbait
Title: Re: ASCII Video Generator
Post by: Dream of Omnimaga on October 20, 2017, 05:23:51 PM
I wonder how is the performance like, considering that some softwares have trouble displaying text at a reasonable speed. Even the TI-84+ OS font display had that problem, to the point where ASM sprites were actually faster