--[[
This script analyzes a BizHawk movie file for blank input frames at the end.
Removing such frames (AKA "Spiking") should reduce movie length without
changing the outcome. Run the script with the movie loaded. I have not tested
this with subframe input. I don't expect it to work with analog controls.
Feel free to improve upon this.
Dacicus 2020/09/29
--]]
local frame_curr, input_curr, spike_this_frame
local spike = {false, 0}
local function process_movie()
for frame_curr = 0, movie.length() - 1 do
spike_this_frame = true
input_curr = movie.getinput(frame_curr)
for k, v in pairs(input_curr) do
if v ~= false then
spike_this_frame = false
end
end
if not spike_this_frame then
spike[1] = false
else
if not spike[1] then
spike = {true, frame_curr}
end
end
end
end
local function print_results()
if spike[1] then
console.writeline("Spike movie from frame " .. spike[2] .. ".")
else
console.writeline("No blank input frames found at end of movie.")
end
end
if movie.isloaded() then
process_movie()
print_results()
else
console.writeline("ERROR: Please load a movie.")
end