def createVideoIcon(file):
"""
Creating a video icon/thumbnail
:type file: str
:param file: path to the file name
:rtype: image
:return: icon/thumbnail for the video
"""
# should install ffmpeg for the method to work successfully
ffmpeg = Utils.checkFFMPEG()
if ffmpeg:
# generate thumbnail
preview = os.path.join(mkdtemp(), hashlib.md5(file) + '.jpg')
try:
os.unlink(preview)
except Exception:
pass
# capture video preview
command = [ffmpeg, '-i', file, '-f', 'mjpeg', '-ss', '00:00:01', '-vframes', '1', preview, '2>&1']
exec_php(command)
return file_get_contents(preview)
评论列表
文章目录