ffmpeg.py 文件源码

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

项目:pyjam 作者: 10se1ucgo 项目源码 文件源码
def run(self):
        file_size_dl = 0
        response = requests.get(self.url, stream=True)
        data_chunks = response.iter_content(chunk_size=1024)

        if not os.path.exists('bin'):
            os.mkdir('bin')

        with open('bin/ffmpeg.7z', 'wb') as f:
            while not self.is_aborted():
                try:
                    chunk = next(data_chunks)
                    file_size_dl += len(chunk)
                    logger.info("FFmpeg downloader: Downloaded chunk: {chunk}".format(chunk=len(chunk)))
                    logger.info("FFmpeg downloader: Total downloaded so far: {total}".format(total=file_size_dl))
                    logger.info("FFmpeg downloader: Remaining: {r}".format(r=self.file_size - file_size_dl))
                    if chunk:
                        f.write(chunk)
                        f.flush()
                        # This makes the download super slow.
                        # os.fsync(f.fileno())
                    wx.CallAfter(self.parent.ff_update, message=file_size_dl)
                except StopIteration:
                    wx.CallAfter(self.parent.ff_complete)
                    break
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号