This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Bomb Bloke's profile picture

RecGif

Started by Bomb Bloke, 07 October 2015 - 11:01 AM
Bomb Bloke #1
Posted 07 October 2015 - 01:01 PM
pastebin get MgMmd2dC recgif

A ComputerCraft screen recorder. Saves your terminal output as an animated GIF.

Requires my GIF API and BBPack, though these should be downloaded automatically if they're missing.

Also requires a Minecraft font file, saved as "ascii.gif". It'll auto-download a low-res one if it's missing, via:

bbpack get Y0eLUPtr

… but, if you don't mind longer encoding times, you can get a high-res one by manually running:

bbpack get QCwtu5sK

The script will use an alternate font if it detects CC 1.76 or later:

bbpack get CnLzL5fg

Which can again be replaced by a high-res version, if you wish:

bbpack get vtKWYMqa

Usage:
recgif [-i] [-s] [-ld:<num>] [scriptToRecord] [scriptArgs ...]

If the -i flag is used, then key/mouse_events will be logged at the bottom of the animation.
If -s is used, then the last frame will be skipped, excluding it from the animation. Handy for those cases where you want to avoid a big red "Terminated" message being captured when you hit Ctrl + T.
If -ld: is used, then it must be followed immediately by a number (no spaces). This sets the delay of the last frame in the animation in seconds. The default is two.
If no script is specified, simply starts another CraftOS shell and records that.

Examples

Version History2015/10/07
1.0.0
Initial release.

2015/10/08
1.0.1
Bug fixes.

2015/10/11
1.1.0
More bug fixes (and the arg bug squashed for reals this time).
Blinking text cursors are now recorded.
User input can now be included in the animations.

2015/12/21
1.1.1
Support for CC1.76's font.

2016/02/01
1.1.2
Fixes to scrolling and CC1.76's new characters.

2016/02/16
1.1.3
Fix for older CC builds.

2016/03/27
1.1.4
Fixes for blinking cursor.
Added -ld and -s parameters.
Default animation delay on end frame reduced from 5s to 2s.

2016/05/06
1.1.5
Fix where final display write may've been omitted from some GIFs.

2016/05/17
1.1.6
Fixes some sort of crash bug. I think.

2017/06/20
1.1.7
Changed "package" references to "bbpack".
Edited on 20 June 2017 - 09:42 AM
Wojbie #2
Posted 07 October 2015 - 02:00 PM
Nice stuff! This will be really useful in creating tutorials and stuff for cc without using recording software. I am so making some recordings with this! One question for you? Is there a reason you went with coorutine.yeld overwrite instead of going coorutine.create and restore like monitor program? I am guessing that messed with timing right?
Edited on 07 October 2015 - 12:00 PM
Bomb Bloke #3
Posted 07 October 2015 - 02:15 PM
Nah, just laziness on my part. Doing it properly (either by sandboxing or a custom coroutine manager) could potentially run slightly faster under uncommon scenarios (eg, people actually using multiple multishell tabs), but it'd make for more lengthy code.
Wojbie #4
Posted 07 October 2015 - 02:27 PM
Also I noticed you are not pcall-ing the shell.run that means that if script to run errors that would error past your code and cause recording to be wasted.
EDIT: Or not? I think I got confused for a moment. I need to test it again.

I had case of dumb-dumb there.

On other note I love how you separated recording and rendering of gif. And the way you piece frames of the gif together.
Edited on 07 October 2015 - 06:38 PM
SquidDev #5
Posted 07 October 2015 - 04:06 PM
Wow! That is some nice code! Having a read through I guess it would be too difficult to show key presses - something like this (and even mouse clicks)? I guess your rendering system isn't really designed for it, though it would be a pretty awesome feature! Heh, using alpha-blending you could even have it as a semi-transparent overlay.
Creator #6
Posted 07 October 2015 - 05:23 PM
Yup, totally, with the 16 available colours.
Wojbie #7
Posted 07 October 2015 - 08:42 PM
I got 3 bugs reports:
  1. If using it to open program and pass arguments to that program they will not be passed due to:
  2. 
    		local arg = {...}
    		shell.run(#arg == 0 and "shell" or unpack(arg))
    		
    part. Because if you return more than one element into logic stuuf only first one is considered rest is discared. In this case only arg[1] is passed. Quick and dirty fix would be to change it to:
    
    		local arg = {...}
    		shell.run(#arg == 0 and "shell" or arg[1],unpack(arg,2))
    		
    .
  3. If attempting to record edit program. It errors on encoding in line 219: Attempt to get length of number.
  4. When tested it don&amp;amp;#39;t seem to happen in other programs.
  5. Looks like last frame is held on screen for about 5 sec. Is that on purpose?
And 1 feature suggestions.
  • When waiting for [y/n] answer can you ignore all other than y/n? Accidentally wiped few recordings by typing filename there. I hate when i am idiot that detects places to idiot-prof code but yea.
On other note something i was making using your RecGif. Showcase for one of my programs:
Bomb Bloke #8
Posted 07 October 2015 - 10:39 PM
Wow! That is some nice code! Having a read through I guess it would be too difficult to show key presses - something like this (and even mouse clicks)? I guess your rendering system isn't really designed for it, though it would be a pretty awesome feature! Heh, using alpha-blending you could even have it as a semi-transparent overlay.

Not much in the way of alpha available in GIF, but in theory I could do something with the 8bit colour depth. Still, it'd be easier to just add an extra few rows of pixels to the bottom of the image and put the text there. I may take a stab at it.

If using it to open program and pass arguments to that program they will not be passed due to:

Thanks, fixed.

If attempting to record edit program. It errors on encoding in line 219: Attempt to get length of number.
When tested it don&amp;amp;#39;t seem to happen in other programs.

Whoops, forgot you could term.write() numbers…

I for one tend to avoid that in my code, as monitors still format them differently to the regular terminal. For some reason.

Looks like last frame is held on screen for about 5 sec. Is that on purpose?

Yes, that's on purpose (line 74 sets the duration).

When waiting for [y/n] answer can you ignore all other than y/n?

Ok.

On other note something i was making using your RecGif. Showcase for one of my programs:

Yes, I figured it'd be useful for that sort of thing. :)/>

Looks like you might want to have it wrap quotes around the argument suggestions with spaces in them.
Bomb Bloke #9
Posted 10 October 2015 - 02:29 PM
Having a read through I guess it would be too difficult to show key presses - something like this (and even mouse clicks)?

Alright, I've added something along those lines - an example animation has been added to the OP. I was considering having the input fade after a while, but I for one type quickly enough that the line tends to run off the screen nearly immediately anyways… I may pretty it up a bit some other day.

I've also dug out a higher resolution font file, which can be optionally downloaded in place of the default low-res one. That was used to create the Bank Vault animation.
Creator #10
Posted 10 October 2015 - 02:35 PM
Can I use RecGif to show a gif of a script I wrote?
Bomb Bloke #11
Posted 10 October 2015 - 02:40 PM
Certainly, users need not ask permission or worry about credit. Go for it. :)/>
Creator #12
Posted 10 October 2015 - 03:42 PM
Ok, thanks!
Creator #13
Posted 10 October 2015 - 04:01 PM
And, by the way, is it normal it takes so long to encode GIFs?
Wojbie #14
Posted 10 October 2015 - 04:03 PM
Yep. One of my long test ones lasted few minutes encoding after recording.
Creator #15
Posted 10 October 2015 - 04:15 PM
Here is the first GIF I made:
Bomb Bloke #16
Posted 11 October 2015 - 01:01 AM
Yep. One of my long test ones lasted few minutes encoding after recording.

Indeed, and things are slower still with the higher-res font.

It actually turned out to be a lot faster than I expected it to be.
Waitdev_ #17
Posted 16 October 2015 - 10:27 AM
awesome. i'm amazed people in computercraft can do things like this.
Bomb Bloke #18
Posted 21 December 2015 - 08:08 AM
Updated with font support for CC1.76 - you'll need to delete your old font file after updating ComputerCraft (ascii.gif). Updates to my Package and GIF APIs recently may mean you'll also need to delete those before running this new version too (it'll automatically download all required files if they're missing).

Spoiler
Edited on 10 February 2016 - 10:05 PM
DvgCraft #19
Posted 15 February 2016 - 05:31 PM
Wow! looks nice! But… It doesn't work.
After it has asked to save and where to save, it starts to save and download the nessessary files. But then, it raises an error:

recgif:190: attempt to index ? (a nil value)
Line 190 says:

local set = ascii[y + ybump][x + xbump] == 1
which references to the place ascii is assigned: (line 177)

local ascii, counter = GIF.toPaintutils(GIF.flattenGIF(GIF.loadGIF(shell.resolve("ascii.gif")))), 0
So I think it has somehing to do with your GIF API.
Any ideas?

EDIT: I'm on CC 1.63
Edited on 15 February 2016 - 04:33 PM
Bomb Bloke #20
Posted 16 February 2016 - 02:13 AM
Urgh, too many versions of ComputerCraft for me to keep track of these days. The GIF API wasn't causing that particular error, but when I corrected it, the API then DID crash out due a floating point problem… both issues were exclusive to older CC builds, though the first of the two was entirely my fault.

So you'll need to remove both the GIF API file as well as RecGif before updating. Don't forget to reboot your ComputerCraft system to force the new copy of the API to load (if it'd already loaded the old copy since its last restart, then it otherwise won't bother to download and load the new one).

I also noticed a bug where the text cursor sometimes gets stuck in the recording where it shouldn't, but I'll have to dig deeper into that when I've got some time. I also need to re-write Package one of these days (the bit which does most of the work, handling all the image compression); there's bound to be some speed improvements to be made there.
Bomb Bloke #21
Posted 27 March 2016 - 04:31 AM
Finally sat down and fixed the cursor problem.

I've also added a couple more optional parameters. -s can now be used to prevent the last frame from being captured, whereas -ld:<num> can be used to set the the display time of the last rendered frame (in seconds) before the animation loops (default is now two seconds, down from five).
houseofkraft #22
Posted 30 October 2016 - 04:54 PM
How do i stop the GIF recording?
Admicos #23
Posted 30 October 2016 - 05:22 PM
How do i stop the GIF recording?
You close the program you are running (the shell, the program on the script arg…)
Edited on 30 October 2016 - 04:23 PM