Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ASCII Animations
#1
Inspired by the thread started by mnrvovrfc (https://qb64phoenix.com/forum/showthread.php?tid=2112), I converted the whole Rick Astley - Never Gonna Give You Up music video to an ASCII animation.

And the code:

Code: (Select All)
Option Explicit
$NoPrefix

Screen NewImage(80, 25)

'You know the rules and so do I
Sleep
Open "B", 1, "rickroll.txt"
Dim As Long x
Dim As String pic, buf
Dim As Long s: s = SndOpen("02 - Rick Astley - Never Gonna Give You Up.flac", "STREAM")
If s Then SndPlay (s)
While Not EOF(1)
    For x = 0 To 24
        If EOF(1) = 0 Then
            Line Input #1, buf
            pic = pic + buf
        End If
    Next
    Cls
    Print Mid$(pic, 2)
    Limit 60
    pic = ""
    If EOF(1) Then Exit While
Wend
Close

Converted the video like this:
1) Download a GIF or video with plain background, preferably white. In my case, I had to get the green screen version of the music video and then use Kdenlive to make it white.
2) Use ffmpeg to convert the video/GIF into a JPEG image sequence
Code: (Select All)
ffmpeg -i rickroll.mkv -vsync 0 rickroll/rickroll_%d.jpg
3) Use a Python script 
.txt   img2ascii.txt (Size: 3.15 KB / Downloads: 43) (save as img2ascii.py) in a bash loop to iterate over each frame and convert them into ASCII text files
Code: (Select All)
#!/bin/bash
for filename in rickroll/*.jpg; do
    sem -j+0 python img2ascii.py --file "$filename" --out rickroll/$(basename "$filename".txt)
done
#you might have to kill this sem call to proceed
sem --wait
cat $(find rickroll/ -name "rickroll_*.jpg.txt" | sort -V) >> rickroll.txt
rm rickroll/rickroll_*.jpg.txt
echo "DONE"
4) Monitor the output of the script. It will tell you how many columns and rows the images are. Set your QB64 up for that many columns and rows for a perfect output!

5) ???
6) Profit


If you don't want to go through all that and just want to run it:
Linux - 
.zip   rickroll_lnx.zip (Size: 30.2 MB / Downloads: 48)
Windows - 
.zip   rickroll_win.zip (Size: 30.51 MB / Downloads: 52)
Tread on those who tread on you

Reply
#2
Applied the same method to the Dragostea Din Tei music video. Not as clean since the background isn't removed.

Tread on those who tread on you

Reply
#3
Found another tool I can run in bash to remove background from images using machine learning. Letting that run on a new video to see how well it does for the ASCII animation project Smile
Tread on those who tread on you

Reply
#4
New processing workflow is quite good and much faster than my old one. Here are a couple of videos made using the new process:


Tread on those who tread on you

Reply
#5
The "Daishabet" has a psychedelic "feeling", don't know how else to describe it. Angel

Too bad it was limited to 20 lines of the terminal, LOL.

Apparently this stuff is too much for:
https://asciinema.org/

"Forget screen-recording apps and blurry video." Yeah, right!
Reply
#6


P.S. asciinema does work with it
Tread on those who tread on you

Reply
#7
(10-21-2023, 07:15 AM)SpriggsySpriggs Wrote: Inspired by the thread started by mnrvovrfc (https://qb64phoenix.com/forum/showthread.php?tid=2112), I converted the whole Rick Astley - Never Gonna Give You Up music video to an ASCII animation.
Thanks for sharing this - I like that you also included the ffmpeg examples! 
This will be fun to play with!
Reply




Users browsing this thread: 3 Guest(s)