neige d'aoust

knowledge, art, and other stuff

User Tools

Site Tools


bts:badapple

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
bts:badapple [2026/02/01 18:26] – created Yukibts:badapple [2026/02/01 20:42] (current) Yuki
Line 7: Line 7:
 </code> </code>
  
-It should play a video. Yeah. It's impressive because curl doesn't play videos. There's even subtitles and a progress bar! Try it for yourself! Incredible.+It should play a video. Yeah. It's impressive because curl isn'meant to play videos. There's even subtitles and a progress bar! Try it for yourself! Incredible. 
 + 
 +how tf did you do that, you say??? 
 + 
 +===== step 1: convert mp4 to braille ===== 
 + 
 +<code bash> 
 +# convert movie to a series of PNGs 
 +ffmpeg -i badapple.mp4 badapple%04d.png 
 +# then convert each PNG using img2braille 
 +clear > badapple.txt 
 +for i in *.png; do 
 +  tput home 
 +  img2braille -d $i 
 +done > badapple.txt 
 +</code> 
 + 
 +===== step 2: uuuuh, do something ===== 
 + 
 +Now dump badapple.txt on a web server and it should work, right? Yeah it's going to be too fast so we probably should slow it down. 
 + 
 +<code bash> 
 +curl --limit-rate 343230 localhost/badapple.txt 
 +</code> 
 + 
 +Okay, no. Too many drop frames. Maybe we should do this server-side. 
 + 
 +<code php> 
 +<?php 
 +$file = "badapple.txt"; 
 + 
 +header('Content-Type: text/plain'); 
 +header('Content-Length: '.filesize($file)); 
 + 
 +$h = fopen($file, "r"); 
 + 
 +echo fread($h, 11); 
 + 
 +$time = microtime(true); 
 +while(!feof($h)) 
 +
 +    echo fread($h, 11441); 
 +    time_sleep_until($time+1/32.5); 
 +    $time = microtime(true); 
 +
 +</code> 
 + 
 +Yeah, it kinda works, now, now to put subtitles and why not a progress bar and also credits at the end and now it's 200 lines of code aaaaa 
 + 
 +===== TODO ===== 
 + 
 +  * japanese characters? 
 +  * sixel
bts/badapple.1769988402.txt.gz · Last modified: by Yuki