also encode audio files
This commit is contained in:
parent
d78ccaeeda
commit
15da3c1d5b
1 changed files with 11 additions and 10 deletions
|
@ -38,17 +38,18 @@ 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)
|
if not os.path.exists(frame_f):
|
||||||
if not os.path.exists(frame_f):
|
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
|
||||||
|
|
Loading…
Reference in a new issue