Skip to content

Instantly share code, notes, and snippets.

@Bilka2
Last active January 30, 2023 04:29
Show Gist options
  • Save Bilka2/579ec217ec38e055328e4a23f2fd71a3 to your computer and use it in GitHub Desktop.
Save Bilka2/579ec217ec38e055328e4a23f2fd71a3 to your computer and use it in GitHub Desktop.
Create a timelapse from a factorio replay save file
-- Just add this to the end of the control.lua file in the save file and then replay the file
-- This sequence is adjusted for https://www.speedrun.com/Factorio/run/mr87xlgy
script.on_nth_tick(300, function(event)
if event.tick < 90000 then
game.take_screenshot{
surface = game.surfaces[1],
position = {-88,-9},
resolution = {1920,1080},
zoom = 0.2,
path = "timelapse/" .. string.format("%06d", event.tick/event.nth_tick) .. ".png",
show_entity_info = true,
allow_in_replay = true
}
elseif event.tick < 218000 then
game.take_screenshot{
surface = game.surfaces[1],
position = {-106,-57},
resolution = {1920,1080},
zoom = 0.2,
path = "timelapse/" .. string.format("%06d", event.tick/event.nth_tick) .. ".png",
show_entity_info = true,
allow_in_replay = true
}
else
game.take_screenshot{
surface = game.surfaces[1],
position = {-112,-167},
resolution = {1920,1080},
zoom = 0.2,
path = "timelapse/" .. string.format("%06d", event.tick/event.nth_tick) .. ".png",
show_entity_info = true,
allow_in_replay = true
}
end
end)
-- this is be the generic code, one screenshot every minute:
--[[
script.on_nth_tick(3600, function(event)
game.take_screenshot{
surface = game.surfaces[1],
position = {0,0},
resolution = {1920,1080},
zoom = 0.2,
path = "timelapse/" .. string.format("%06d", event.tick/event.nth_tick) .. ".png",
show_entity_info = true,
allow_in_replay = true
}
end)
]]
@Bilka2
Copy link
Author

Bilka2 commented Oct 29, 2018

FFmpeg command to convert to a video (15 fps):
ffmpeg -framerate 15 -i %06d.png -s hd1080 -vcodec libx264 -r 30 timelapse.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment