我们现在有几个bucket里的视频全部要使用七牛云的在线转码转完存储到另外一个bukcet里头
获取文件
- # -*- coding: utf-8 -*-
- # flake8: noqa
- from qiniu import Auth
- from qiniu import BucketManager
- access_key = 'Access_Key'
- secret_key = 'Secret_Key'
- #初始化Auth状态
- q = Auth(access_key, secret_key)
- #初始化BucketManager
- bucket = BucketManager(q)
- #你要测试的空间, 并且这个key在你空间中存在
- bucket_name = 'Bucket_Name'
- key = 'python-logo.png'
- #获取文件的状态信息
- ret, info = bucket.stat(bucket_name, key)
- print(info)
- assert 'hash' in ret
复制代码
持续性转码
- # -*- coding: utf-8 -*-
- # flake8: noqa
- from qiniu import Auth, PersistentFop, build_op, op_save, urlsafe_base64_encode
- #对已经上传到七牛的视频发起异步转码操作
- access_key = 'Access_Key'
- secret_key = 'Secret_Key'
- q = Auth(access_key, secret_key)
- #要转码的文件所在的空间和文件名。
- bucket = 'Bucket_Name'
- key = '1.mp4'
- #转码是使用的队列名称。
- pipeline = 'mpsdemo'
- #要进行转码的转码操作。
- fops = 'avthumb/mp4/s/640x360/vb/1.25m'
- #可以对转码后的文件进行使用saveas参数自定义命名,当然也可以不指定文件会默认命名并保存在当前空间
- saveas_key = urlsafe_base64_encode('目标Bucket_Name:自定义文件key')
- fops = fops+'|saveas/'+saveas_key
- pfop = PersistentFop(q, bucket, pipeline)
- ops = []
- ops.append(fops)
- ret, info = pfop.execute(key, ops, 1)
- print(info)
- assert ret['persistentId'] is not None
复制代码
我想批量直接进行转码怎么写这个文件呢(问了客服 官方面板不支持批量转码 必须使用SDK)
而且不给教程
真是B了狗了 |