Utils.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:Instagram-API 作者: danleyb2 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号