由于项目中用到视频水印功能,通过程序效率相对比较低。
最后决定先把视频上传到七牛,然后调用api给指定视频加上水印功能,具体实现
//初始化AK,SK string sACCESS_KEY = "七牛账号对应的AK"; string sSECRET_KEY = "七牛账号对应的SK"; string namekey = DateTime.Now.ToString("HHmmss")+".mp4"; byte[] b = System.Text.Encoding.Default.GetBytes("watermark:" + namekey);//将水印视频放入 watermark存储空间 String saveasURL = Convert.ToBase64String(b); //保存到-目标空间下的文件 string fops = "avthumb/mp4/wmText/Ymlhbw==http://www.likecs.com/wmFontColor/cmVk/wmFontSize/30/wmGravityText/SouthEast|saveas/" + saveasURL; //执行命令,部分是字符base64 string pipeline = "watermark_line"; string notifyUrl = "";//成功回调的URL string bucket = "znmlr"; //目标空间 string key = "hello.mp4"; //文件名 Mac mac = new Mac(sACCESS_KEY, sSECRET_KEY); Pfop px = new Pfop(mac); PfopResult result = px.pfop(bucket, key, fops, pipeline, notifyUrl, true); if (result.PersistentId == null) { string ss = result.Response; } Console.WriteLine(JsonConvert.SerializeObject(result)); Console.ReadLine();