public static void videoHls(long id, String directory, String m3u8Directory, String queueName) { //待处理文件所在空间 String bucket = "待处理文件所在空间"; //待处理文件名 // http://www.123.com/openclass/video/2615/1汉语拼音及相关知识.mp4 String key = "openclass/video/" + directory + ".文件后缀"; Auth auth = Auth.create(ACCESS_KEY, SECRET_KEY); //数据处理指令,支持多个指令 String saveMp4Entry = String.format("%s%s", "open-class-hls-2:openclass/video-hls/", m3u8Directory + ".m3u8"); //指定空间、文件名 // avthumb/m3u8/segtime/10/ab/128k/ar/44100/acodec/libfaac/r/30/vb/1000k/vcodec/libx264/stripmeta/0| String avthumbMp4Fop = String.format("avthumb/m3u8/segtime/10/ab/128k/ar/44100/acodec/libfaac/r/30/vb/1000k/vcodec/libx264/stripmeta/0/refine/1|" + "saveas/" + "%s", UrlSafeBase64.encodeToString(saveMp4Entry)); //将多个数据处理指令拼接起来 String persistentOpfs = StringUtils.join(new String[]{avthumbMp4Fop}, ";"); //数据处理队列名称,必须 String persistentPipeline = queueName; //数据处理完成结果通知地址 String persistentNotifyUrl = "http://www.回调地址.com?id=" + id; //构造一个带指定 Region 对象的配置类 Zone z = Zone.autoZone(); Configuration cfg = new Configuration(z); //构建持久化数据处理对象 OperationManager operationManager = new OperationManager(auth, cfg); try { String persistentId = operationManager.pfop(bucket, key, persistentOpfs, persistentPipeline, persistentNotifyUrl, true); //可以根据该 persistentId 查询任务处理进度 System.out.println(persistentId); OperationStatus operationStatus = operationManager.prefop(persistentId); //解析 operationStatus 的结果 System.out.println(JSONObject.toJSONString(operationStatus)); } catch (QiniuException e) { System.err.println(e.response.toString()); } }
来源:oschina
链接:https://my.oschina.net/648885471/blog/3207296