Skip to content

Instantly share code, notes, and snippets.

@dubhater
Created November 19, 2013 10:37
Show Gist options
  • Save dubhater/7543480 to your computer and use it in GitHub Desktop.
Save dubhater/7543480 to your computer and use it in GitHub Desktop.
A script that makes sure tdecimate doesn't screw up your perfect Yatta IVTC.
#!/usr/bin/env python3
import sys
def print_usage():
print("Prints the frame numbers of cycles that don't have decimation overrides.")
print("\nUsage:")
print("{} file.dec.txt [frame_count]".format(sys.argv[0]))
print("\nNote: if the frame count is not specified, the cycles after the last cycle with overrides will be disregarded.")
if len(sys.argv) < 2 or len(sys.argv) > 3:
print_usage()
print("\nError: invalid number of arguments.")
sys.exit(1)
ovr_file_name = sys.argv[1]
cycle_length = 5
frame_count = 0
if len(sys.argv) == 3:
frame_count = int(sys.argv[2])
cycles_with_overrides = [-1]
cycles_without_overrides = []
with open(ovr_file_name, "r") as f:
i = 0
for line in f:
i += 1
bits = line.split(' ')
if len(bits) != 2:
print("Error: bad override at line {}".format(i))
sys.exit(1)
cycles_with_overrides.append(int(bits[0]) // cycle_length)
if len(cycles_with_overrides) == 0:
print("No cycles have overrides.")
sys.exit(0)
if frame_count != 0:
cycles_with_overrides.append(((frame_count - 1) // cycle_length) + 1)
for i in range(1, len(cycles_with_overrides)):
diff = cycles_with_overrides[i] - cycles_with_overrides[i-1]
if diff > 2:
cycles_without_overrides.append([(cycles_with_overrides[i-1] + 1)*cycle_length, (cycles_with_overrides[i] - 1)*cycle_length])
elif diff > 1:
cycles_without_overrides.append((cycles_with_overrides[i] - 1)*cycle_length)
if len(cycles_without_overrides) > 0:
print("The cycles starting at the following frame numbers don't have decimation overrides:")
for cycles in cycles_without_overrides:
print(cycles)
else:
print("It appears all cycles have decimation overrides.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment