flat assembler
Message board for the users of flat assembler.
Index
> Windows > [Demo] Short MP4 "video" in console screen |
Author |
|
FlierMate1 19 Jun 2022, 18:18
Firstly, thanks to bitRAKE for his code snippet to split string (https://board.flatassembler.net/topic.php?t=21996)
This is a simple demo showing short MP4 "video" in Windows command prompt window. Limitation: Don't know how to resize to bigger window I am asking for code on how to allocate memory buffer, because I have another 4MB car racing "video" file which is impossible to play with my existing code. Please let me know what you think about this. (The "video" file is split using "$" character, generated by myself from sample MP4 using FFMPEG) Code: format PE console entry start include 'win32a.inc' section '.data' data readable writable _filename db "airplane.mp4.txt",0 _buffer rb 464728 _handle dd ? _console dd ? _len dd ? section '.code' code readable executable start: push 0 push FILE_ATTRIBUTE_NORMAL push OPEN_EXISTING push 0 push FILE_SHARE_READ push GENERIC_READ push _filename call [CreateFile] cmp eax, INVALID_HANDLE_VALUE mov dword [_handle], eax je .error push STD_OUTPUT_HANDLE call [GetStdHandle] mov dword [_console], eax push 0 push _len push 464728 push _buffer push dword [_handle] call [ReadFile] test eax, eax jz .error call Play .error: push 0 call [ExitProcess] Play: ; String split iterator (bitRAKE) ; ; RDI: string to scan ; RCX: length of string in characters, >0 ; AX: character to split on lea edi, [_buffer] mov ecx, dword [_len] .scan: mov al, '$' mov esi, edi repnz scasb push edi jnz .last sub edi, 1 ; don't count the split character in length .last: push ecx sub edi, esi ; length without terminator ;jz skip push 0 ; FUNCTION (address:RSI, length:RDI) push 0 push edi push esi push dword [_console] call [WriteConsole] push 200 call [Sleep] .skip: pop ecx ; characters to go pop edi ; start cmp ecx, 0 jz .done jmp .scan .done: ret section '.idata' import readable writable library kernel32, 'KERNEL32.DLL' import kernel32,\ GetStdHandle, 'GetStdHandle', \ WriteConsole, 'WriteConsoleA', \ GetTickCount, 'GetTickCount', \ Sleep, 'Sleep', \ CreateFile, 'CreateFileA', \ ReadFile, 'ReadFile', \ ExitProcess,'ExitProcess'
Last edited by FlierMate1 on 21 Jun 2022, 14:11; edited 2 times in total |
||||||||||||||||||||
19 Jun 2022, 18:18 |
|
bitRAKE 20 Jun 2022, 08:16
With windows 10 MS is pushing towards better VT100 support - so, everything old is new again. I was just thinking the other day of coding a little program to display some of the old terminal animations. There are interesting effects like twinkling stars and stuff that looked cool at 300 baud. The stuff people were able to do in such a constrained environment in quite amazing.
_________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
20 Jun 2022, 08:16 |
|
FlierMate1 20 Jun 2022, 15:48
@I, thanks for the code, it works as expected. The default console window size on my Windows is actually big enough, 120x30, to fit my animated ASCII art.
I wrote: Maybe MapViewOfFile for file? This sounds like a cool API function. I will study more if I need to cater for large file. bitRAKE wrote: I was just thinking the other day of coding a little program to display some of the old terminal animations...The stuff people were able to do in such a constrained environment in quite amazing. I think you also mean demoscene coders back in the old days. Like...bad apple ? ( https://en.wikipedia.org/wiki/Bad_Apple!!#Use_as_a_graphical_and_audio_test ) Thanks for your "string split " code again! |
|||
20 Jun 2022, 15:48 |
|
FlierMate1 20 Jun 2022, 16:05
The animated ASCII art was converted from this real MP4 using a simple algorithm:
https://www.videvo.net/video/ek-boeing-777-landing/4036/
Last edited by FlierMate1 on 21 Jun 2022, 14:26; edited 2 times in total |
||||||||||
20 Jun 2022, 16:05 |
|
FlierMate1 21 Jun 2022, 06:12
It is not only that, can also applies color to the ASCII art, hence, ANSI art. But I had tested it before, it is slower when playing the animated ANSI art.
Not just from MP4 video, ASCII art can also be converted from animated GIF frame by frame. I plan to create a complete ASCII/ANSI art Studio (convert & play), but not sure its usefulness, or if there is any similar tool on GitHub already.
|
|||||||||||||||||||
21 Jun 2022, 06:12 |
|
bitRAKE 21 Jun 2022, 07:11
https://www.ansilove.org/ is the one I know of. Back in the BBS days I think most of them were created by hand, with very limited colors/characters.
Have you seen Picnic's Hobby Basic? He's included some ANSI art amongst his example programs. (I haven't tried them on the latest Win10/11, but they should work even better, imho.) _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
21 Jun 2022, 07:11 |
|
FlierMate1 21 Jun 2022, 14:02
Interestingly, "ansilove" does the opposite, it converts ANSI art to PNG image file.
Yes, I too notice those are created by hand. I am aware of Picnic's HB, but have never downloaded it before. It is an interpreter and closed-source. From his thread, yes, I too notice ANSI art created by hand. (I tried to download HB.zip but Windows reported 'Failed - Virus detected', I have disabled the Real-time Virus &Threat Protection before this, but suddenly have no clue where to turn off App & Browser Control ) Also, from your String Split Iterator, I forgot to set the ECX to length of string, and it still work, must be based on random value in ECX register. |
|||
21 Jun 2022, 14:02 |
|
bitRAKE 21 Jun 2022, 16:34
FlierMate1 wrote: I tried to download HB.zip but Windows reported 'Failed - Virus detected', I have disabled the Real-time Virus &Threat Protection before this _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
21 Jun 2022, 16:34 |
|
Picnic 21 Jun 2022, 21:49
Hello FlierMate1, bitRAKE,
FlierMate1 wrote: I am aware of Picnic's HB, but have never downloaded it before. It is an interpreter and closed-source. From his thread, yes, I too notice ANSI art created by hand. Sorry to hear that. HB.zip is clean. Still, Windows refuses to run it (or even download it sometimes) unless the the Real-time Virus & Threat Protection is disabled. Nevertheless, if you manage to skip Windows security you'll see that HB runs quite smooth in Windows 10. bitRAKE wrote: If I had to contend with MS's definition of security [beyond disabling it] then I doubt I could use Windows. It's more like a bit religion where some oracle in the sky says, "these bits are bad" and millions of machines echo "these bits are bad". There always needs to be bad bits - how else you going to know how protected you are? Recently i download s suspicious file. I knew it and took my chances. I lost an external disk (it locked and asking me for money to unlock it). Windows 10 didn't complain about anything, my AV the same. |
|||
21 Jun 2022, 21:49 |
|
FlierMate1 22 Jun 2022, 08:10
Picnic wrote:
I understand, my experimental compiler also went through the same issue, falsely detected by Windows (and several other AVs) as malware. I remember must turn off several other settings besides Virus & Threat Protection to successfully download certain .Zip files. Thank you for the kind message, Picnic. |
|||
22 Jun 2022, 08:10 |
|
revolution 22 Jun 2022, 09:04
But how to convince the mainstream users when they fully believe all the AV marketing about how foolproof AVs are?
You upload your code to some place, and then the users demand it be removed because of the dangerous nasty viruses inside. And then your account if banned. And then you get onto a blacklist that the sites share with each other. Last edited by revolution on 22 Jun 2022, 11:40; edited 2 times in total |
|||
22 Jun 2022, 09:04 |
|
Ali.Z 22 Jun 2022, 11:35
a campaign, "AV is PUP"
_________________ Asm For Wise Humans |
|||
22 Jun 2022, 11:35 |
|
bitRAKE 24 Jun 2022, 17:51
Picnic wrote: Recently i download s suspicious file. I knew it and took my chances. I lost an external disk (it locked and asking me for money to unlock it). Windows 10 didn't complain about anything, my AV the same. The process I imagine is boot into BIOS, load image off network. This requires a backup process if work is to persist across images. It makes all local drives disposable. Maybe loose a day of work, but zero down time. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
24 Jun 2022, 17:51 |
|
FlierMate11 21 Jan 2023, 06:58
Hi, my first demo example in Post #1 is far from perfect, as it doesn't set to larger console screen window, and it doesn't set cursor position back to 0,0 on every frame redraw.
Now I fixed this. Thanks to @I for your good code. Below is API call in each of the console app player: Code: call [CreateFile] call [GetStdHandle] call [ReadFile] call [GetConsoleScreenBufferInfoEx] call [SetConsoleScreenBufferInfoEx] call [GetConsoleWindow] call [SetWindowPos] loop: call [SetCursorPos] call [WriteConsole] call [Sleep] call [ExitProcess] Please choose to download which object you want to watch (airplane landing, racing car, moon & earth), each of this Zip file contains .asm source file, .exe executable and .mp4.txt character video. However, once you launch the player, you cannot interrupt it until it finishes playing. The longest character video is car.mp4.txt with about 800 frames. Frames are delimited with "$" (dollar sign) character. Correction: Oops, SetCursorPos is used to set cursor position of mouse pointer, not screen cursor. I have commented the relevant code and recompiled them.
|
|||||||||||||||||||||||||||||||
21 Jan 2023, 06:58 |
|
MatQuasar 01 Mar 2024, 13:41
MP4TXT
Your favorite character video in text mode screen. Old thing is new again, it is animated ASCII art, also known as character video. What are included in this repo? I have prepared three different animation files, each with its own console player. They are racing car, landing airplane, and moon & earth, with racing car animation file being the largest, with about 800 frames. How to play these animations? Please compile the console player with flat assembler 1, preferably using its IDE, FASMW.EXE. Then place the animation file ending with .mp4.txt together with console player executable in the same directory. Finally, run the executable file to see the animation in console window. Command Prompt window is preferred than other command processor. There might be issue with window resizing with Windows Terminal. So make sure you use Command Prompt as the default command processor to get the best result. Can you elaborate more about these character video? Well, each of these character video was converted from sample MP4 which is loyalty-free. Frames were extracted from MP4 video using FFMPEG command-line tool, then each extracted image file was further converted to ASCII art using a simple algorithm. I automate this using a script, but I did not publish the script online. Each of these ASCII art are all inside a larger text file, delimited using $ (dollar sign) character. You can make use of the three animation files (ending in .mp4.txt) and play it in programming language of your favourites. For instance, you can play the character video in .NET using WinForms text box control by setting to fixed width font at 3pt for better result than using the Command Prompt window. People have been using my animation files to load and play using JavaScript as well. Lastly, I will mention how to convert an image file to ASCII art: Just find out the intensity of a pixel, and convert to 16 different punctuation marks according to the intensity. ASCII art is one thing, ANSI art is another. While I have been successful in converting images to both ASCII art and ANSI art, I do not have much success in playing animated colorful ANSI art. An ANSI art is 16-color and I have my own algorithm to reduce RGB color to 16 color palette. But that is another story. I hope you enjoy my animated ASCII art! |
|||
01 Mar 2024, 13:41 |
|
QuasiMoGnome 05 Apr 2024, 09:13
bitRAKE wrote:
I have (or had) a large collection of MS-DOS era viruses, some of which are very rare samples. I pulled them off a dying hard drive once, and when I installed the new one I created the directory for them and excluded it from MS antivirus realtime scans, then started extracting the ZIP they were in to that directory, from that directory. It took me a minute to notice that Defender was spewing warnings and it "disinfected" a bunch of them and the ZIP. It turned out that unzipping them was copying them to C:\temp first instead of doing it in-place and that triggered the scans. I have no idea why, but thanks 7-zip. Anyway one of the disinfected files had a .bin extension and was a raw boot sector of michaelangelo or one of the stoned variants that not only couldn't run on its own, but couldn't do anything on a GPT boot disk, only worked on 360k floppies, and used the POP CS instruction for an intersegment long jump which was only valid on the 8088 (not to mention that almost all of these were pure 16 bit code and I'm on a 64-bit OS with the subsystem to run them removed) so there was no way I could injure a computer with it if I tried without buying a museum piece. Keep that in mind when some antivirus talks about how they detect over 50,000 threats or whatever. Edit: This happened in 2019 on Windows 10, btw. |
|||
05 Apr 2024, 09:13 |
|
uu 08 Sep 2024, 09:13
I modified the luna.asm a little bit and now the video is interruptible with Esc key.
Full source: Code: format PE console entry start include 'win32a.inc' struct CONSOLE_SCREEN_BUFFER_INFOEX cbSize dd ? dwSize dd ? dwCursorPosition dd ? wAttributes dw ? srWindow rd 2 dwMaximumWindowSize dd ? wPopupAttributes dw ? bFullScreenSupported dd ? ColorTable rd 10h ends LEN equ 711141 section '.data' data readable writable _filename db "luna.mp4.txt",0 _buffer rb LEN _handle dd ? _console dd ? _len dd ? _csbi CONSOLE_SCREEN_BUFFER_INFOEX section '.code' code readable executable start: push 0 push FILE_ATTRIBUTE_NORMAL push OPEN_EXISTING push 0 push FILE_SHARE_READ push GENERIC_READ push _filename call [CreateFile] cmp eax, INVALID_HANDLE_VALUE mov dword [_handle], eax je .error push STD_OUTPUT_HANDLE call [GetStdHandle] mov dword [_console], eax push 0 push _len push LEN push _buffer push dword [_handle] call [ReadFile] test eax, eax jz .error mov [_csbi.cbSize],sizeof.CONSOLE_SCREEN_BUFFER_INFOEX push _csbi push [_console] call [GetConsoleScreenBufferInfoEx] mov [_csbi.dwSize],160 or (40 shl 16) mov [_csbi.srWindow],0 mov [_csbi.srWindow+4],160 or (40 shl 16) mov [_csbi.dwMaximumWindowSize],160 or (40 shl 16) push _csbi push [_console] call [SetConsoleScreenBufferInfoEx] call [GetConsoleWindow] push SWP_NOSIZE push 0 push 0 push 10 push 40 push -1 push eax call [SetWindowPos] call Play .error: push 0 call [ExitProcess] Play: ; String split iterator (bitRAKE) ; ; RDI: string to scan ; RCX: length of string in characters, >0 ; AX: character to split on lea edi, [_buffer] mov ecx, dword [_len] .scan: mov al, '$' mov esi, edi repnz scasb push edi jnz .last sub edi, 1 ; don't count the split character in length .last: push ecx sub edi, esi ; length without terminator ;jz skip ;push 0 ;push 0 ;call [SetCursorPos] push 0 ; FUNCTION (address:RSI, length:RDI) push 0 push edi push esi push dword [_console] call [WriteConsole] push 100 call [Sleep] push 0x1B ;ESC key call [GetKeyState] bt eax, 15 ; If the high-order bit is 1, the key is down; otherwise, it is up jnc .skip add esp, 8 jmp .done .skip: pop ecx ; characters to go pop edi ; start ;cmp ecx, 0 jcxz .done jmp .scan .done: ret section '.idata' import readable writable library kernel32, 'KERNEL32.DLL',\ user32,'USER32.DLL' import kernel32,\ GetStdHandle, 'GetStdHandle', \ WriteConsole, 'WriteConsoleA', \ GetTickCount, 'GetTickCount', \ Sleep, 'Sleep', \ CreateFile, 'CreateFileA', \ ReadFile, 'ReadFile', \ ExitProcess,'ExitProcess', \ GetConsoleWindow,'GetConsoleWindow',\ GetConsoleScreenBufferInfoEx,'GetConsoleScreenBufferInfoEx',\ SetConsoleScreenBufferInfoEx,'SetConsoleScreenBufferInfoEx' import user32,\ SetWindowPos,'SetWindowPos',\ SetCursorPos,'SetCursorPos',\ GetKeyState, 'GetKeyState' You can do the same with airplane.asm and car.asm by adding line 116~121 and the last line. You might have problem downloading the Zip files above because Chrome blocked it and marked it as malware. |
|||
08 Sep 2024, 09:13 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.