also encode audio files

This commit is contained in:
j 2013-05-03 17:29:34 +02:00
parent d78ccaeeda
commit 15da3c1d5b

View file

@ -38,17 +38,18 @@ def encode(filename, prefix, profile, info=None, extract_frames=True):
oshash = info['oshash']
frames = []
cache = os.path.join(prefix, os.path.join(*utils.hash_prefix(oshash)))
if info.get('video'):
if extract_frames:
for pos in utils.video_frame_positions(info['duration']):
frame_name = '%s.png' % pos
frame_f = os.path.join(cache, frame_name)
if not os.path.exists(frame_f):
print frame_f
extract.frame(filename, frame_f, pos)
frames.append(frame_f)
if info.get('video') and extract_frames:
for pos in utils.video_frame_positions(info['duration']):
frame_name = '%s.png' % pos
frame_f = os.path.join(cache, frame_name)
if not os.path.exists(frame_f):
print frame_f
extract.frame(filename, frame_f, pos)
frames.append(frame_f)
if info.get('video') or info.get('audio'):
media_f = os.path.join(cache, profile)
if not os.path.exists(media_f):
if not os.path.exists(media_f) \
or os.stat(media_f).st_size == 0:
extract.video(filename, media_f, profile, info)
else:
print info