use stream height by default

This commit is contained in:
j 2012-02-17 13:02:04 +05:30
parent 31713e5f3b
commit 81748afa2d
2 changed files with 6 additions and 3 deletions

View file

@ -241,7 +241,7 @@ def frame(videoFile, frame, position, height=128, redo=False):
videoFile input
frame output
position as float in seconds
width of frame
height of frame
redo boolean to extract file even if it exists
'''
if exists(videoFile):

View file

@ -850,7 +850,7 @@ class Item(models.Model):
'''
Video related functions
'''
def frame(self, position, height=128):
def frame(self, position, height=None):
offset = 0
streams = self.streams()
for stream in streams:
@ -858,7 +858,10 @@ class Item(models.Model):
offset += stream.duration
else:
position = position - offset
height = min(height, stream.resolution)
if not height:
height = stream.resolution
else:
height = min(height, stream.resolution)
path = os.path.join(settings.MEDIA_ROOT, stream.path(),
'frames', "%dp"%height, "%s.jpg"%position)
if not os.path.exists(path) and stream.video: