10-21-2023, 07:15 AM
(This post was last modified: 10-21-2023, 09:38 AM by SpriggsySpriggs.)
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:
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
3) Use a Python script
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
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 -
rickroll_lnx.zip (Size: 30.2 MB / Downloads: 46)
Windows -
rickroll_win.zip (Size: 30.51 MB / Downloads: 50)
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
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"
5) ???
6) Profit
If you don't want to go through all that and just want to run it:
Linux -
rickroll_lnx.zip (Size: 30.2 MB / Downloads: 46)
Windows -
rickroll_win.zip (Size: 30.51 MB / Downloads: 50)
Tread on those who tread on you