Jump to content




RecGif

utility

22 replies to this topic

#1 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,096 posts
  • LocationTasmania (AU)

Posted 07 October 2015 - 12: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 History

Edited by Bomb Bloke, 20 June 2017 - 10:42 AM.


#2 Wojbie

  • Members
  • 630 posts
  • LocationKinda lost

Posted 07 October 2015 - 01: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 by wojbie, 07 October 2015 - 01:00 PM.


#3 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,096 posts
  • LocationTasmania (AU)

Posted 07 October 2015 - 01: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.

#4 Wojbie

  • Members
  • 630 posts
  • LocationKinda lost

Posted 07 October 2015 - 01: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 by wojbie, 07 October 2015 - 07:38 PM.


#5 SquidDev

    Frickin' laser beams

  • Members
  • 1,389 posts
  • LocationDoes anyone put something serious here?

Posted 07 October 2015 - 03: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.

#6 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 07 October 2015 - 04:23 PM

Yup, totally, with the 16 available colours.

#7 Wojbie

  • Members
  • 630 posts
  • LocationKinda lost

Posted 07 October 2015 - 07:42 PM

I got 3 bugs reports:
  • If using it to open program and pass arguments to that program they will not be passed due to:
    		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))
    		
    .
  • If attempting to record edit program. It errors on encoding in line 219: Attempt to get length of number.
    When tested it don&amp;#39;t seem to happen in other programs.
  • 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:
Posted Image

#8 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,096 posts
  • LocationTasmania (AU)

Posted 07 October 2015 - 09:39 PM

View PostSquidDev, on 07 October 2015 - 03:06 PM, said:

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.

View Postwojbie, on 07 October 2015 - 07:42 PM, said:

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

Thanks, fixed.

View Postwojbie, on 07 October 2015 - 07:42 PM, said:

If attempting to record edit program. It errors on encoding in line 219: Attempt to get length of number.
When tested it don&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.

View Postwojbie, on 07 October 2015 - 07:42 PM, said:

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).

View Postwojbie, on 07 October 2015 - 07:42 PM, said:

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

Ok.

View Postwojbie, on 07 October 2015 - 07:42 PM, said:

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.

#9 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,096 posts
  • LocationTasmania (AU)

Posted 10 October 2015 - 01:29 PM

View PostSquidDev, on 07 October 2015 - 03:06 PM, said:

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.

#10 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 10 October 2015 - 01:35 PM

Can I use RecGif to show a gif of a script I wrote?

#11 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,096 posts
  • LocationTasmania (AU)

Posted 10 October 2015 - 01:40 PM

Certainly, users need not ask permission or worry about credit. Go for it. :)

#12 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 10 October 2015 - 02:42 PM

Ok, thanks!

#13 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 10 October 2015 - 03:01 PM

And, by the way, is it normal it takes so long to encode GIFs?

#14 Wojbie

  • Members
  • 630 posts
  • LocationKinda lost

Posted 10 October 2015 - 03:03 PM

Yep. One of my long test ones lasted few minutes encoding after recording.

#15 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 10 October 2015 - 03:15 PM

Here is the first GIF I made:Posted Image

#16 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,096 posts
  • LocationTasmania (AU)

Posted 11 October 2015 - 12:01 AM

View Postwojbie, on 10 October 2015 - 03:03 PM, said:

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.

#17 Waitdev_

  • Members
  • 432 posts
  • LocationWherever you want me to be

Posted 16 October 2015 - 09:27 AM

awesome. i'm amazed people in computercraft can do things like this.

#18 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,096 posts
  • LocationTasmania (AU)

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 by Bomb Bloke, 10 February 2016 - 11:05 PM.


#19 DvgCraft

  • Members
  • 14 posts
  • LocationThe Netherlands

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 by DvgCraft, 15 February 2016 - 05:33 PM.


#20 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,096 posts
  • LocationTasmania (AU)

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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users