SHARE
TWEET

Untitled

a guest Jul 17th, 2017 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import sys
  2.  
  3. framebefore = int(sys.argv[1])
  4. total = int(sys.argv[2]) if len(sys.argv) == 4 else framebefore+10
  5. filename = sys.argv[-1]
  6.  
  7. convert = [i for i in range(total)]
  8.  
  9. with open(filename) as decimate:
  10.     decimateframes = []
  11.     for line in decimate:
  12.         dec = int(line.strip()[:-2])
  13.         if dec > total:
  14.             break
  15.         decimateframes.append(dec)
  16. current = 0
  17. sub = 0
  18.  
  19. # insert decimated frames according to cycle of 5, if not in dec file
  20. for cycle in range(0,total,5):
  21.     cycledecimated = False
  22.     for cycleframe in range(cycle,cycle+5):
  23.         if cycleframe in decimateframes:
  24.             cycledecimated = True
  25.             break
  26.     if not cycledecimated:
  27.         decimateframes.append(cycle)
  28.  
  29. decimateframes.sort()
  30.        
  31. for currentdec in decimateframes:
  32.     while current-1 != currentdec and current < total:
  33.         convert[current] -= sub
  34.         current += 1
  35.  
  36.     if current + 1 < total:
  37.         sub += 1
  38.  
  39.         convert[current] -= sub if current > 0 else 0
  40.         current += 1
  41.  
  42. print("Frame before decimation:",framebefore)
  43. print("Frame after decimation:",convert[framebefore])
RAW Paste Data
Top