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: 46)
Windows - 
.zip   rickroll_win.zip (Size: 30.51 MB / Downloads: 51)
Tread on those who tread on you

Reply


Messages In This Thread
ASCII Animations - by SpriggsySpriggs - 10-21-2023, 07:15 AM
RE: ASCII Animations - by SpriggsySpriggs - 10-21-2023, 04:13 PM
RE: ASCII Animations - by SpriggsySpriggs - 10-21-2023, 05:08 PM
RE: ASCII Animations - by SpriggsySpriggs - 10-22-2023, 10:05 PM
RE: ASCII Animations - by mnrvovrfc - 10-22-2023, 10:13 PM
RE: ASCII Animations - by SpriggsySpriggs - 10-22-2023, 11:16 PM
RE: ASCII Animations - by madscijr - 10-27-2023, 10:55 PM



Users browsing this thread: 1 Guest(s)