rename Movie to Item

This commit is contained in:
j 2010-09-23 18:01:48 +02:00
commit 2ad4abd820
14 changed files with 657 additions and 250 deletions

View file

@ -326,7 +326,7 @@ def divide(num, by):
arr.append(div + (i > by - 1 - mod))
return arr
def timeline_strip(movie, cuts, info, prefix):
def timeline_strip(item, cuts, info, prefix):
_debug = False
duration = info['duration']
video_height = info['video'][0]['height']
@ -353,29 +353,29 @@ def timeline_strip(movie, cuts, info, prefix):
c = cuts.index(frame)
if c +1 < len(cuts):
duration = cuts[c + 1] - cuts[c]
stills = math.ceil(duration / (video_width * timeline_height / video_height))
widths = divide(duration, stills)
still = frame
frames = math.ceil(duration / (video_width * timeline_height / video_height))
widths = divide(duration, frames)
frame = frame
if _debug:
print widths, duration, stills, cuts[c], cuts[c + 1]
for s in range(int(stills)):
still_ratio = widths[s] / timeline_height
if video_ratio > still_ratio:
width = int(round(video_height * still_ratio))
print widths, duration, frames, cuts[c], cuts[c + 1]
for s in range(int(frames)):
frame_ratio = widths[s] / timeline_height
if video_ratio > frame_ratio:
width = int(round(video_height * frame_ratio))
left = int((video_width - width) / 2)
box = (left, 0, left + width, video_height)
else:
height = int(round(video_width / still_ratio))
height = int(round(video_width / frame_ratio))
top = int((video_height - height) / 2)
box = (0, top, video_width, top + height)
if _debug:
print frame, 'cut', c, 'still', s, still, 'width', widths[s], box
#FIXME: why does this have to be still+1?
frame_image = Image.open(movie.frame((still+1)/fps))
print frame, 'cut', c, 'frame', s, frame, 'width', widths[s], box
#FIXME: why does this have to be frame+1?
frame_image = Image.open(item.frame((frame+1)/fps))
frame_image = frame_image.crop(box).resize((widths[s], timeline_height), Image.ANTIALIAS)
for x_ in range(widths[s]):
line_image.append(frame_image.crop((x_, 0, x_ + 1, timeline_height)))
still += widths[s]
frame += widths[s]
if len(line_image) > frame:
timeline_image.paste(line_image[frame], (x, 0))
if x == timeline_width - 1: