Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2

Author Topic: CMV to GIF  (Read 8443 times)

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
CMV to GIF
« on: January 22, 2015, 05:54:18 pm »

CMVtoGIF - Generate GIF animations from Dwarf Fortress CMV files
======================================================

This little program takes any Dwarf Fortress CMV file and creates a GIF animation from it.

Different types of CMVs have different frame rates, so it may take a little bit of tweaking
to get a nice looking GIF image, but in general things should "just work".

Basics
----------------------------------------------------------------------------------------------------

Using CMVtoGIF is easy, simply open a command prompt and run:

   cmvtogif -cmv="<cmv file>"

Gameplay CMVs generally need the following settings (else they are too slow):

   cmvtogif -cmv="<cmv file>" -skip=4

There are other options you may use to control exactly what is converted and how.
For example if you want a GIF of just the fight scene in the dwarf fortress intro,
cropped to a smaller size and slower than normal, something like this will do:

   cmvtogif -start=78 -end=88 -x=18 -w=42 -delay=15 -cmv=dwarf_fortress.cmv -gif=fight_scene.gif

Use the `-tset` option to specify a tileset, by default `tileset.png` is used.
Tile size is calculated from the tile sheet dimensions, non-square tilesets should
work fine.

Frame skipping and delay
----------------------------------------------------------------------------------------------------

Gameplay CMVs generally are waaaay too slow, use something like this for them:

   cmvtogif -cmv="<cmv file>" -skip=4

This will cause it to render every "skip" frames, in this case for every 5 frames 1
will be rendered. This is not too bad as DF renders the frames the same way (if your
GFPS is lower than your FPS, which is the case normally)

Frame skipping is required because, with the default settings for DF, a gameplay CMV
is 100 FPS! Way too fast for the GIF format to display :)

The delay value is how long to wait between frames, setting this higher will slow the
animation down. CMVs store a delay internally, but if (like me) you think this is too
fast you can change it to whatever you want.

If you want to decrease file size for the generated animation simply increase the delay
and frame skip values. This will make the animation have a lower frame rate while still
playing at the same speed... If that makes any sense?

Having the frame skip or delay set too high can make the animation rough and ugly, so
don't do that!

These two setting may require some experimentation to get right, if you modify one the
value for the other will likely have to change as well.

Building
----------------------------------------------------------------------------------------------------

I provide 32 bit Windows binaries, but if you want binaries for other architectures or
operating systems you will have to build them yourself.

Building is simple, first install [go](golang.org), then unpack CMVtoGIF somewhere on
your GOPATH. Once that is done all you need to do is run `go build CMVtoGIF`.

CMVtoGIF should build and run without issues on every platform go supports (which is
most of them).

Other
----------------------------------------------------------------------------------------------------

By default the GIF is "optimized", eg each frame only contains the tiles that changed
from the previous frame. If this is not desired it is possible to switch this behavior
off with `-opt=false`. Be warned that rendering will be MUCH slower with this disabled!

If possible frames are rendered individually on multiple CPU cores, so multi-core
computers will be able to render large animations MUCH faster than single core computers.
Even so if you try to render a large animation with optimization and frame skipping off
expect to wait a while!

For a full list of command line parameters and their defaults run `cmvtogif -help`.

This program should be able to handle both the "old" and the "new" (with sound) CMV formats.

Compressed CMVs (the CCMV format) are not supported, AFAIK DF cannot generate these files
anyway. If you want support for these files send me a copy of the format specification
and I'll see what I can do...

Have Fun!

Contact:

* User "milo christiansen" on Bay12 forums (preferred)
* milo (dot) christiansen (at) gmail (dot) com (slow but reliable)

Download on DFFD
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

Vattic

  • Bay Watcher
  • bibo ergo sum
    • View Profile
Re: CMV to GIF
« Reply #1 on: January 22, 2015, 07:01:16 pm »

Nice work. Look forward to seeing how people put it to use.
Logged
6 out of 7 dwarves aren't Happy.
How To Generate Small Islands

Button

  • Bay Watcher
  • Plants Specialist
    • View Profile
Re: CMV to GIF
« Reply #2 on: January 23, 2015, 11:04:02 am »

Excellent. Wish I'd had this last week.

I'd actually forgotten that DF even has a video recording function, since there was no easy way to export.
Logged
I used to work on Modest Mod and Plant Fixes.

Always assume I'm not seriously back

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: CMV to GIF
« Reply #3 on: January 23, 2015, 03:09:15 pm »

I could see making Gifs for manuals. That seems like the most reasonable application.

That, or story forts with animated sieges or little comics. :D
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

lethosor

  • Bay Watcher
    • View Profile
Re: CMV to GIF
« Reply #4 on: January 24, 2015, 05:44:46 pm »

There is also BenLubar's cmv2gif utility (although I can't recall how it handles tilesets).
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

BenLubar

  • Bay Watcher
  • [BODY:HUMANOID_LEGLESS_6ARMS]
    • View Profile
Re: CMV to GIF
« Reply #5 on: January 24, 2015, 07:00:30 pm »

There is also BenLubar's cmv2gif utility (although I can't recall how it handles tilesets).

https://github.com/BenLubar/df2014/blob/master/cmv2gif/main.go#L21-L25

You can basically do cmv2gif -t tileset.png last_record.cmv and it'll spit out last_record.gif. By default it uses the 10x12 tileset that comes with Dwarf Fortress.
Logged

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: CMV to GIF
« Reply #6 on: January 27, 2015, 05:31:29 pm »

But how does it handle the fact that gameplay CMVs are 100 FPS?

My version allows you to skip frames and change the frame delay, or even crop the CMV to a smaller size.



I would like to make a DFHack script that takes a single frame CMV of the current view, basically a way to take screen shots that can be rendered at whatever size you want later :)

Does anyone know if it is possible to trigger the recording code from DFHack?
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

BenLubar

  • Bay Watcher
  • [BODY:HUMANOID_LEGLESS_6ARMS]
    • View Profile
Re: CMV to GIF
« Reply #7 on: January 29, 2015, 06:42:38 pm »

But how does it handle the fact that gameplay CMVs are 100 FPS?

My version allows you to skip frames and change the frame delay, or even crop the CMV to a smaller size.



I would like to make a DFHack script that takes a single frame CMV of the current view, basically a way to take screen shots that can be rendered at whatever size you want later :)

Does anyone know if it is possible to trigger the recording code from DFHack?

I've figured out how to turn it on, but not how to turn it off without closing the whole program.

https://github.com/BenLubar/df-ai/blob/master/ai/camera.rb#L23-L31
Logged

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: CMV to GIF
« Reply #8 on: February 06, 2015, 04:22:38 pm »

Interesting, I can't help much (I don't know ruby) but I hope you can get it all working.

One possible problem is TWBT based tilesets, oh well.
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

mifki

  • Bay Watcher
  • works secretly...
    • View Profile
    • mifki
Re: CMV to GIF
« Reply #9 on: February 06, 2015, 04:40:44 pm »

One possible problem is TWBT based tilesets, oh well.

I can add screen recording to TWBT (well, once I have time to add anything to it), but only if someone will make a tool to play them (convert to GIFs too for example), because standard CMV tools won't open them obviously.

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: CMV to GIF
« Reply #10 on: February 06, 2015, 04:44:19 pm »

Give me a spec, and CMVtoGIF will support it.

A player on the other hand would require proper realtime rendering to the display, and if I could find a go library that allowed me to do that I would be making my own game :p

EDIT: I may have finally found working-on-windows SDL bindings for go, wish me luck...
« Last Edit: February 06, 2015, 05:11:35 pm by milo christiansen »
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: CMV to GIF
« Reply #11 on: February 20, 2015, 11:40:08 am »

Ok! Got SDL working and made a basic CMV player (and found+fixed a bug in the GIF converter while I was at it).

The new download includes the player, have fun!
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

Lightman

  • Bay Watcher
  • The groboclones are looking for you.
    • View Profile
Re: CMV to GIF
« Reply #12 on: June 16, 2015, 12:50:51 am »

This didn't work with the default 16x16 .png file in data/art.  There's just a bunch of coloured squares moving around.  It wouldn't accept the .bmp version.
Logged

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: CMV to GIF
« Reply #13 on: June 17, 2015, 11:54:17 am »

The bmp version will not work because I didn't write a bmp image loader, the png version probably didn't work because it lacks transparency, use a tileset that has proper transparency instead of that outdated magenta-is-transparent method.
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: CMV to GIF
« Reply #14 on: June 19, 2015, 01:28:41 am »

Can it do the reverse?
Logged
Pages: [1] 2