Skip to content
Browse files

some minor fixes and changes

  • Loading branch information...
1 parent 99b446c commit de0a86a12894d83df9ff48274b794f9695eb42d5 freder committed Apr 22, 2011
Showing with 45 additions and 2 deletions.
  1. +2 −0 01_new-project.py
  2. +2 −0 02_2_save-scenes.py
  3. +5 −0 02_3_shot-slitscan.py
  4. +1 −2 03_3_movie-colors.py
  5. +35 −0 lib.py
View
2 01_new-project.py
@@ -29,6 +29,8 @@ def main():
os.chdir(os.path.join(PROJECTS_DIR_NAME, project_dir))
tree.write("project.xml")
+ print "don't forget to crop / remove any black borders!"
+
raw_input("- done -")
return
View
2 02_2_save-scenes.py
@@ -20,6 +20,8 @@ def main():
movie = tree.getroot()
# frame count
movie.set("frames", str( frames[-1] - frames[0] ))
+ movie.set("start_frame", str( frames[0] ))
+ movie.set("end_frame", str( frames[-1] - 1 ))
tree.write("project.xml")
f = open(os.path.join(os.getcwd(), "shots.txt"), "w")
View
5 02_3_shot-slitscan.py
@@ -25,6 +25,11 @@ def main():
cap = cv.CreateFileCapture(file_path)
cv.QueryFrame(cap)
+ # skip frames in the beginning, if neccessary
+ start_frame = int( movie.attrib["start_frame"] )
+ for i in range(start_frame):
+ cv.QueryFrame(cap)
+
f = open("shots.txt", "r")
lines = [line for line in f if line]
f.close()
View
3 03_3_movie-colors.py
@@ -119,11 +119,10 @@ def main():
cv.CvtColor(output_img, output_img_rgb, cv.CV_HLS2BGR)
cv.SaveImage("_RESULT.png", output_img_rgb)
+ os.chdir( r"..\.." )
f = open("colors.txt", "w")
row = cv.GetRow(output_img_rgb, 0)
- os.chdir(project_root_dir)
-
counter = 0
last_px = cv.Get1D(row, 0)
for i in range(WIDTH):
View
35 lib.py
@@ -113,3 +113,38 @@ def hsv_sort(a, b): # HSV
return -1
else:
return 0"""
+
+import math
+def timecode_to_seconds(tc):
+ # 00:12:34,567
+ h = int(tc[0:2])
+ m = int(tc[3:5])
+ s = int(tc[6:8])
+ milli = int(tc[-3:])
+ return (milli/1000.0) + s + (m*60) + (h*60*60)
+
+
+def seconds_to_timecode(s):
+ h = int(math.floor(float(s) / (60*60)))
+ m = int(math.floor(float(s) % (60*60)) / 60)
+ s = s - (m*60) - (h*60*60)
+
+ if h > 10:
+ h = str(h)
+ else:
+ h = "0" + str(h)
+
+ if m > 10:
+ m = str(m)
+ else:
+ m = "0" + str(m)
+
+ if s > 10:
+ s = str(s)
+ else:
+ s = "0" + str(s)
+
+ s = s.replace('.', ',')[:6]
+ s = s + (6 - len(s)) * "0"
+
+ return h + ":" + m + ":" + s

0 comments on commit de0a86a

Please sign in to comment.
Something went wrong with that request. Please try again.