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,8 +38,7 @@ def encode(filename, prefix, profile, info=None, extract_frames=True):
oshash = info['oshash'] oshash = info['oshash']
frames = [] frames = []
cache = os.path.join(prefix, os.path.join(*utils.hash_prefix(oshash))) cache = os.path.join(prefix, os.path.join(*utils.hash_prefix(oshash)))
if info.get('video'): if info.get('video') and extract_frames:
if extract_frames:
for pos in utils.video_frame_positions(info['duration']): for pos in utils.video_frame_positions(info['duration']):
frame_name = '%s.png' % pos frame_name = '%s.png' % pos
frame_f = os.path.join(cache, frame_name) frame_f = os.path.join(cache, frame_name)
@ -47,8 +46,10 @@ def encode(filename, prefix, profile, info=None, extract_frames=True):
print frame_f print frame_f
extract.frame(filename, frame_f, pos) extract.frame(filename, frame_f, pos)
frames.append(frame_f) frames.append(frame_f)
if info.get('video') or info.get('audio'):
media_f = os.path.join(cache, profile) 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) extract.video(filename, media_f, profile, info)
else: else:
print info print info